Another gotcha with for loops: scoping is a little weird.
xs := []int{1,2,3}
for _, x := range xs {
go func() {
fmt.Println(x)
}()
}
That prints `3 3 3` not `1 2 3`. You can fix it like this: for i := range xs {
x := xs[i]
go func() {
fmt.Println(x)
}()
}
Which seems like it ought to be the default behavior.