A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-110.go
1packagemain
2
3import"fmt"
4
5typeEstruct{}
6
7func(e*E)Error()string{return"boom"}
8
9funcfind()error{
10varp*E
11returnp
12}
13
14funcmain(){
15fmt.Println(find()==nil)
16}
Interfaces
Answer & explanation
Console output
false
Why
This is the single most common Go bug: returning a typed nil pointer as an error. Although p is a nil *E, wrapping it in the error interface gives the interface a concrete type (*E), so the interface is not nil. Always return a literal nil, not a typed nil variable, when you mean "no error".