↓ Skip to main content

“Loop variables being per-loop instead of per-iteration is the only design decision I know of in Go that makes programs incorrect more often than it makes them correct.”

Russ Coxgithub.com ↗

Go has promised not to change the meaning of existing code. Russ Cox wants one exception, because the loop variable bug has been biting people for a decade and every Go programmer writes “x := x” to dodge it. The fix gets gated on each module’s go.mod line so nobody’s old code breaks overnight. Admitting a language design mistake is rare. Fixing it without breaking the world is rarer.