Re:Nil in Go is typed in theory and sort of untyped in practice
by siebenmann on Wednesday March 31, 2021 @07:02PM
(#26654274)
Attempting to call a method on a nil interface value produces a runtime panic. Otherwise, it is the type that implements an interface, and it's possible that the type works even if the specific value of the type is nil. For instance, you could have a 'myIntPointer' type that is a pointer to an int, and implement a String() method for myIntPointer, and at that point a nil myIntPointer still has a String() method and implements the fmt.Stringer interface (although it may get a runtime panic if you actually call the method).
[ Parent
| on HN ]
There are no comments on this comment yet.