Closed
Description
What version of Go are you using (go version
)?
go1.15 windows/amd64
What did you do?
I am returning exported interface from a method/function and when I do check if it is nil, it never is.
If i return pointer to a struct matching the interface instead of interface, the nil check works as expected.
This is inconsistent, for example with error interface.
Example: https://play.golang.org/p/ghzg8n1fx_y
In my code, when I do:
if r := something(); r != nil {
... // here i can print the r and it will print as nil so it shouldn't have passed the if check
}
What did you expect to see?
If I return nil exported interface I would expect nil check to work properly.
What did you see instead?
Nil check did not work properly when nil is returned from a function as exported interface.