A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-156.go
1packagemain
2
3import"fmt"
4
5funcmain(){
6deferfmt.Println("A")
7deferfmt.Println("B")
8deferfmt.Println("C")
9fmt.Println("start")
10}
Defer
Answer & explanation
Console output
start
C
B
A
Why
Deferred calls are pushed onto a per-function stack and executed in last-in-first-out order when the surrounding function returns. The normal body runs to completion first (printing "start"), then the stack unwinds: C was deferred last so it runs first, followed by B then A.