3 ms·
Yes, "nil interface vs nil value" is _eminently_ unintuitive and incredibly easy to get wrong: https://dev.to/mokiat/the-dark-side-of-go-interfaces-1541 https:
by ttymck 3y ago
Yes, "nil interface vs nil value" is _eminently_ unintuitive and incredibly easy to get wrong:
https://dev.to/mokiat/the-dark-side-of-go-interfaces-1541 https://dev.to/mokiat/the-dark-side-of-go-interfaces-1541
- earthboundkid 3y agoI dunno, ISTM it's like complaining that "0" != 0 in Go (it does in weakly typed languages like JS). A nil pointer and a nil interface are different types, and Go lets you call methods on nil pointers, so it would be weird if it treated nil pointers as special interface values.