Lucky hour! Grab a free trial license — offer ends in 00:59:58. Claim now
The analyzer has detected a redundant type check.
The example:
func foo(rwc io.ReadWriteCloser) io.Reader {
....
return rwc.(io.Reader)
}
Checking the rwc.io.Reader type makes no sense, since the io.ReadWriteCloser type of the rwc parameter, embeds the io.Reader interface.
The fixed code:
func foo(rwc io.ReadWriteCloser) io.Reader {
....
return rwc
}
Checking whether an expression has the empty interface type (interface{} or any) also makes no sense, since every type embeds such an interface. The example:
func foo(rwc io.ReadWriteCloser) interface {} {
....
return rwc.(interface{})
}
The fixed code:
func f(rwc io.ReadWriteCloser) interface {} {
....
return rwc
}
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders: