Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
tyho
· 1y ago · 0 comments
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
Comments
[–]
teivah
1y ago
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).
[–]
yndoendo
1y ago
I still need to support Windows 7 in my industry. The last supported version is 1.20. Outdated is relative.
[–]
tyho
OP
1y ago
I wrote some code today and I relied on the new behaviour. I felt a little dirty.
[–]
josefx
1y ago
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?