A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-179.go
1packagemain
2
3import"fmt"
4
5typePstruct{xint}
6
7func(p*P)Bump(){fmt.Println(p.x)}
8
9funcmain(){
10p:=&P{x:3}
11deferp.Bump()
12p.x=7
13fmt.Println("mutated")
14}
Defer
Answer & explanation
Console output
mutated
7
Why
The receiver evaluated at defer-time is the pointer p, but it is copied as a pointer. It still references the same underlying struct. p.x = 7 mutates that shared struct, so when the deferred Bump runs it dereferences the pointer and reads the updated 7. This is the key contrast with a value receiver.