Go race detector found a data race
April 30, 2026 · View on GitHub
Playbook ID: go-data-race
Category: test
Severity: high
Tags: go, race, concurrency, data-race, test
What this failure means
The Go race detector identified a data race: two goroutines accessed the same memory location concurrently, with at least one performing a write, without any synchronization between them.
Common log signals
WARNING: DATA RACE
DATA RACE
Previous read at
Previous write at
Read at 0x
Write at 0x
Goroutine.*running
PASS (race)
Diagnosis
The Go race detector identified a data race: two goroutines accessed the same memory location concurrently, with at least one performing a write, without any synchronization between them.
Fix steps
- Read the full race report — it shows both goroutine stacks and the file/line for each conflicting access.
- Protect the shared variable with
sync.Mutexorsync.RWMutex, or use an atomic operation (sync/atomic) for simple counters. - Replace concurrent map access with
sync.Mapor add async.RWMutexaround reads and writes. - For loop-variable captures: copy the variable into a local before launching the goroutine:
v := v. - Run locally to reproduce:
go test -race ./...orgo test -race -count=5 ./...for intermittent races.
Validation
- Re-run the local reproduction command after the fix.
- go test -race ./...
- go test -race -count=10 ./path/to/package
Likely files to inspect
**/*.go
Run Faultline
faultline analyze build.log
faultline explain go-data-race
faultline workflow build.log --json --mode agent
Search phrases this page answers
- Go race detector found a data race
- Test: go race detector found a data race
- WARNING: DATA RACE
- faultline explain go-data-race
- Go go race detector found a data race
Generated from playbooks/bundled/log/test/go-data-race.yaml. Do not edit directly — run make docs-generate.