Skip to content

Instantly share code, notes, and snippets.

@Codefor
Last active June 8, 2017 16:15
Show Gist options
  • Save Codefor/937aef583ea625a830a71eceaf455c91 to your computer and use it in GitHub Desktop.
Save Codefor/937aef583ea625a830a71eceaf455c91 to your computer and use it in GitHub Desktop.
fatal error: concurrent map iteration and map write; fatal error: concurrent map writes
package main
import (
// "fmt"
"time"
)
func main() {
m := map[int]int{}
go func() {
for i := 0; i < 1000000; i++ {
m[i] = i
}
}()
for {
for i := 0; i < 1000000; i++ {
//for k, _ := range m {
// k = k * 2
//}
k := len(m)
k = k * 2
}
}
for {
time.Sleep(time.Second / 100)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment