3 ms·
The single example given here is incorrect. Since Go 1.22 loop variables have per-iteration scope, the "broken" code is deterministic and correct. https://go.d
by tyho 1y ago
The single example given here is incorrect. Since Go 1.22 loop variables have per-iteration scope, the "broken" code is deterministic and correct.
https://go.dev/blog/loopvar-preview https://go.dev/blog/loopvar-preview
- teivah 1y agoOutdated I'd rather say :) I documented here https://100go.co/#not-being-careful-with-goroutines-and-loop-variables-63 https://100go.co/#not-being-careful-with-goroutines-and-loop... but you're right, it was fixed (alongside 2 other mistakes in the 100).
- josefx 1y agoThat was an issue in 2023? Quite sure C# fixed something similar back in 2012. Is Go still proudly reinventing the wheel, wooden and filled with termites?