The following code results in an index out of range error. Intuitively I cans see it must be because the loop index is somehow global to the go routine, but I don't understand the details and would appreciate some insight.
package main
import "fmt"
func main() {
t := [10]int{0,0,0,0,0,0,0,0,0,0}
for i := 0; i < 10; i++{
fmt.Println("Routine", i)
go func(){
test(&t, i)
}()
}
fmt.Scanln()
}
func test(t *[10]int, i int){
fmt.Println("testing", t[i])
}