The same fix in a classic for i++ loop

Changes in new versions / Go 1.22

var funcs []func()

// *** before: ***
for i := 0; i < 3; i++ {
    funcs = append(funcs, func() {
        fmt.Println(i) // all three functions see the same i
    })
}
// funcs[0](), funcs[1](), funcs[2]() print "3 3 3"

// *** in version 1.22: ***
for i := 0; i < 3; i++ {
    funcs = append(funcs, func() {
        fmt.Println(i) // each iteration gets its own i
    })
}
// funcs[0](), funcs[1](), funcs[2]() print "0 1 2"