concurrent map writes panic from a background goroutine
Production panic: fatal error: concurrent map writes goroutine 34 [running]: main.(*Cache).Set(...) /app/cache.go:22 I have a map[string]Item used as a cache, written by several goroutines and read by the HTTP handlers. I thought reads were safe if I wasn't resizing. Clearly not. What's the right structure here, RWMutex or sync.Map? Ideally I'd understand why reads are fine but writes are not before I pick a structure, since this cache is central.
4 replies