← Back to archive

Stdle #135 · defer · 2026-10-19

What does this Go snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

package main
import "fmt"
func main() {
defer fmt.Println("A")
defer func() {
if r := recover(); r != nil {
fmt.Println("R:", r)
}
}()
defer fmt.Println("B")
panic("P")
}
Defer
3 lines
4 attempts left

Answer & explanation