The "concurrent map writes" panic occurs because Go maps are not safe for use by multiple goroutines simultaneously without external synchronization. Wrap all map read and write operations in a sync.Mutex to serialize access and prevent the race condition.
var (
mu sync.Mutex
data = make(map[string]int)
)
// Writing
mu.Lock()
data[key] = value
mu.Unlock()
// Reading
mu.Lock()
val := data[key]
mu.Unlock()