|
|
|
|
|
by inlined
2551 days ago
|
|
This. Nil is the one case where you can seriously screw your self up in Go because it’s an untyped literal that gets typed on assignment. Interfaces are fat pointers and a “true” nil pointer is nil interface, nil implementation. If your function is going to return a known subtype and you store that nil in a temporary you now return a known interface and nil implementation. Then your == nil check on the interface pointer will fail. I royally screwed up a deploy once because my functions were returning nil error implementations that were != nil and triggered failure paths. |
|