https://go.dev/doc/articles/race_detector
So this example with loop variable
func main() {
var wg sync.WaitGroup
wg.Add(5)
for i := 0; i < 5; i++ {
go func() {
fmt.Println(i) // Not the 'i' you are looking for.
wg.Done()
}()
}
wg.Wait()
}
Should it have note with a link on loopvar-preview page?
Or should it be added new example like
func main() {
var wg sync.WaitGroup
wg.Add(5)
var i int
for i = 0; i < 5; i++ {
go func() {
fmt.Println(i) // Not the 'i' you are looking for.
wg.Done()
}()
}
wg.Wait()
}
https://go.dev/doc/articles/race_detector
So this example with loop variable
Should it have note with a link on loopvar-preview page?
Or should it be added new example like