I have the following code:
package main
import "fmt"
func main() {
fmt.Println(interface{}(1) == interface{}(1))
var a *int
fmt.Println(a == nil)
fmt.Println(interface{}(a) == interface{}(nil))
}
and it outputs:
true
true
false
I'm wondering why. In the first case it can be seen that wrapping a value in an interface{}
doesn't stop equality from being determined, and yet a nil pointer (which is equal to nil
) wrapped in an interface{}
is not the same as interface{}(nil)
. Why is this?