February 8, 2026
Closures vs Coffee
(Golang) Self referential functions and the design of options
Go dev’s ‘undoable options’ spark battle: elegant or headache
TLDR: A Go dev unveiled “undoable” option functions—they set a value and return a function to revert it. The community split: admirers praised elegance, while critics like sneak called it “too clever by half,” insisting Go favors simple, sleepy-time readability over clever wizardry.
A Go developer proposed a slick way to set and reset configuration options: instead of knobs and switches, you pass in tiny functions that set a value and even return a built‑in “undo” function. Think an option with its own reverse gear—an undo button baked into the code. The idea evolved from returning “previous state” values to full-on self-referential functions that return their inverse. Simple description, spicy reactions.
The thread lit up. The loudest take? Go should be readable by someone “one drink in,” not a puzzle box of clever closures. User sneak blasted it as “too clever by half,” a vibe many Gophers echoed: Go prides itself on boring, predictable code. Fans countered with “less boilerplate, more flexibility,” praising the elegance and composability. Memes flew: “Haskell cosplay,” “wizard hat spotted,” and “Go devs allergic to fun.” Some loved the undo trick; others warned it’s like hiding a trapdoor in the floor—neat until you fall through at 3 a.m. The drama boiled down to culture: team boring Go vs. team clever closure, with readability, debugging nightmares, and vibes over vibes. Even the idea of returning previous values sparked jokes about type assertions and mystery boxes. Classic Go internet.
Key Points
- •Initial design defines option as func(*Foo) applied via a variadic Option method on *Foo.
- •Each option is provided as a function returning a closure that sets a specific field (e.g., Verbosity(v int)).
- •To support temporary configuration, option evolves to func(*Foo) interface{} so previous values can be returned and later restored.
- •Restoring via interface{} requires a type assertion when reapplying the previous value.
- •A further refinement makes option self-referential (func(*Foo) option), returning an inverse option to restore prior state without type assertions.