← Back to archive

Stdle #163 · defer · 2026-11-16

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("cleanup")
defer fmt.Println("close file")
defer fmt.Println("rollback")
fmt.Println("work done")
}
Defer
4 lines
4 attempts left

Answer & explanation