Hacker News new | ask | show | jobs
by tyho 437 days 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

2 comments

Outdated I'd rather say :) I documented here https://100go.co/#not-being-careful-with-goroutines-and-loop... but you're right, it was fixed (alongside 2 other mistakes in the 100).
I still need to support Windows 7 in my industry. The last supported version is 1.20. Outdated is relative.
I wrote some code today and I relied on the new behaviour. I felt a little dirty.
That 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?