monogon-dev / monogon

The Monogon Monorepo. May contain traces of peanuts and a ✨pure Go Linux userland✨. Work in progress!
https://monogon.tech
Apache License 2.0
378 stars 8 forks source link

Loop behaviour in Go 1.22 #299

Closed q3k closed 3 months ago

q3k commented 3 months ago

Go 1.22 changed the semantics of for loop variables. This was arguably an annoying feature of the language, so we would like to use the new behaviour.

We should check whether this is actually enabled for us, or whether we need to take some extra steps here.

fionera commented 3 months ago

Running the example code from https://go.dev/blog/loopvar-preview with go.mod set to 1.21 has the correct behavior.

INFO: Running command line: bazel-bin/metropolis/bla/bla_/bla
c
a
b