目次 mapの競合状態とは何か? どうしたらいいのか? sync.RWMutexを使う 共有ロックと排他ロック sync.Mapを使う atomic.Valueを使う ロックとCompare and swap さいごに 感想 mapの競合状態とは何か? GoのmapはあるgoroutineでReadしているときに別のgoroutineからWriteしてはいけないというルールがある。 もし違反するとpanicを起こす。 このことはgo1.6のリリースノートに書いてある(他の出典を探したけど見つけられなかった・・) Go 1.6 Release Notes - The Go Programming Language if one goroutine is writing to a map, no other goroutine should be reading or writing the