Canonical guidance

Use when

Avoid

Preferred pattern

for i := 0; i < len(s); i++ {
	use(s[i])
}

Anti-pattern

Explanation: This is tempting because the closure is nearby, but loop variable semantics deserve explicit review whenever execution is deferred.

Why

Related pages

Sources