# Go: WARNING: DATA RACE — Write at 0x00c0000 by goroutine 7: / Previous read at ... by goroutine 6

**Code:** `WARNING: DATA RACE` · **Category:** Go · **Seen on:** Go

The race detector (`-race`) observed two goroutines accessing the same memory concurrently with at least one write and no synchronisation.

## 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

1. Protect shared data with `sync.Mutex` or use channels
2. Use `atomic.AddInt64` for counters
3. Copy loop variables or upgrade to Go 1.22

## Detailed fix by platform

### Go

1. `go test -race ./...` and `go run -race .`

## How to diagnose

1. **Report** — Which two accesses?
2. **State** — Shared how?
3. **Fix** — Mutex/atomic/channel?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/go/data-race-detected)
