A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-75.go
1packagemain
2
3import"fmt"
4
5funcmain(){
6deferfmt.Println("one")
7fmt.Println("two")
8deferfmt.Println("three")
9fmt.Println("four")
10}
Defer
Answer & explanation
Console output
two
four
three
one
Why
A defer statement only schedules its call; execution is postponed until the function returns. The body prints "two" then "four" in order. At return the deferred calls unwind LIFO: "three" (registered second) runs before "one" (registered first).