V8024. Redundant type assertion. The type of a variable already embeds the type that is checked using type assertion.
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
}