Fix

"concurrent map writes" in Go

Fix the concurrent map writes panic in Go by wrapping all map access with a sync.Mutex to ensure thread-safe operations.

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()