A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-47.go
1packagemain
2
3import"fmt"
4
5typeTstruct{}
6
7funcmain(){
8varp*T
9variinterface{}=p
10_,ok:=i.(*T)
11fmt.Println(i==nil,ok)
12}
Interfaces
Answer & explanation
Console output
false true
Why
Storing a nil *T in an interface produces a typed nil: i has type *T with a nil value, so i == nil is false. Yet the dynamic type is genuinely *T, so the assertion i.(*T) succeeds and ok is true. This shows the nil-interface gotcha and type assertions are about the type word, not the value being nil.