You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw err == nil: false in the output. I suspect this has to do with what is mentioned in the laws of reflection: that instead of err having a pure nil value, it's pointing to the (value, type) tuple (nil, *Err). However, I don't understand why this would be desirable.
Thank you for your time!
The text was updated successfully, but these errors were encountered:
Basically, nil is overloaded. It is the zero value of both pointer types and interface types (and also map, slice, function, and channel types). It is entirely reasonable to store a nil pointer into a variable of interface type. Such a value is no longer the zero value of its type, so comparing it with nil (this time the nil interface value, not the nil pointer value) must be false.
What version of Go are you using (
go version
)?Though I think this works on all recent versions ... ?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://play.golang.org/p/wYWX4cDk3rc
What did you expect to see?
I expected
err == nil
to returntrue
.What did you see instead?
I saw
err == nil: false
in the output. I suspect this has to do with what is mentioned in the laws of reflection: that instead oferr
having a purenil
value, it's pointing to the (value, type) tuple (nil
,*Err
). However, I don't understand why this would be desirable.Thank you for your time!
The text was updated successfully, but these errors were encountered: