# WARNING: DATA RACE
写操作地址 0x... 位于 goroutine N:
  main.foo()
此前的读操作地址 0x... 位于 goroutine M:
  main.bar()

- **ID:** `go/race-detector-warning`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

两个 goroutine 在无同步的情况下访问同一内存位置，且至少有一个是写操作。仅在 -race 构建时能被检测到。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.1+ | active | — | — |

## 解决方案

1. **** (97% 成功率)
   ```
   var mu sync.Mutex
mu.Lock()
counter++
mu.Unlock()
// or
atomic.AddInt64(&counter, 1)
   ```
2. **** (92% 成功率)
   ```
   for _, item := range items {
    item := item // capture by value
    go func() { process(item) }()
}
   ```

## 无效尝试

- **** — Does not create a happens-before relationship between the two accesses; race detector still fires. (90% 失败率)
- **** — Hides real bugs; production may corrupt data or crash non-deterministically. (95% 失败率)
