← Back to archive

Stdle #119 · defer · 2026-10-03

What does this Go snippet output?

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

package main
import "fmt"
func f() (s string) {
defer func() { s = "deferred" }()
return "returned"
}
func main() {
r := f()
fmt.Println(r)
}
Defer
4 attempts left

Answer & explanation