← Back to archive

Stdle #91 · defer · 2026-09-05

What does this Go snippet output?

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

package main
import "fmt"
type M struct{ tag string }
func (m M) Get() string { return m.tag }
func main() {
m := M{tag: "A"}
defer fmt.Println(m.Get())
defer fmt.Println(m.tag)
m.tag = "B"
fmt.Println("now", m.tag)
}
Defer
3 lines
4 attempts left

Answer & explanation