← Back to archive

Stdle #21 · defer · 2026-06-27

What does this Go snippet output?

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

package main
import "fmt"
func main() {
defer func() {
if r := recover(); r != nil {
fmt.Println("ok")
}
}()
var m map[string]int
m["a"] = 1
}
Defer
4 attempts left

Answer & explanation