github.com/glycerine/zebrapack@v4.1.1-0.20181107023619-e955d028f9bf+incompatible/slides/state-of-go/runtime/mapcrash.go (about) 1 /// +build OMIT 2 3 package main 4 5 import ( 6 "fmt" 7 "sync" 8 ) 9 10 func main() { 11 const workers = 100 // what if we have 1, 2, 25? 12 13 var wg sync.WaitGroup 14 wg.Add(workers) 15 m := map[int]int{} 16 for i := 1; i <= workers; i++ { 17 go func(i int) { 18 for j := 0; j < i; j++ { 19 m[i]++ // HL 20 } 21 wg.Done() 22 }(i) 23 } 24 wg.Wait() 25 fmt.Println(m) 26 }