Go: WARNING: DATA RACE — Write at 0x00c0000 by goroutine 7: / Previous read at ... by goroutine 6
The race detector (-race) observed two goroutines accessing the same memory concurrently with at least one write and no synchronisation.
WARNING: DATA RACEWARNING: DATA RACE Write at by goroutinePrevious read at by goroutinetesting.go: race detected during execution of testFound 1 data race(s) Meaning
The report lists the conflicting accesses with stack traces and where the goroutines were created. Fix by synchronising (mutex, channel, atomic) or removing shared mutable state. Loop variable capture in closures is a classic source (fixed per-iteration in Go 1.22).
Common causes
- Shared variable without mutex
- Closure capturing a loop variable (Go < 1.22)
- Concurrent map/slice access
- Unsynchronised counters (use sync/atomic)
- Global state mutated by handlers
⚡ Quick fix
- Protect shared data with
sync.Mutexor use channels - Use
atomic.AddInt64for counters - Copy loop variables or upgrade to Go 1.22
Detailed fix by platform
Go
go test -race ./...andgo run -race .
How to diagnose
- Report — Which two accesses?
- State — Shared how?
- Fix — Mutex/atomic/channel?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Go
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026