A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-161.go
1packagemain
2
3import"fmt"
4
5typeTstruct{}
6
7funcget()*T{returnnil}
8
9funcmain(){
10variinterface{}=get()
11fmt.Println(i==nil)
12}
Interfaces
Answer & explanation
Console output
false
Why
An interface value is nil only when BOTH its type and value are nil. Here get() returns (*T)(nil): the value part is nil, but the type part is *T, so the interface is non-nil. This is the famous Go nil-interface gotcha: a typed nil stored in an interface compares as not equal to nil.