# WARNING: DATA RACE
Goroutine 5 在 0x00c0000b4010 处写入：

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

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.18 | active | — | — |
| 1.21 | active | — | — |
| 1.23 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   var counter atomic.Int64
counter.Add(1)
n := counter.Load()
   ```
2. **** (92% 成功率)
   ```
   ch := make(chan int)
go func() { ch <- compute() }()
result := <-ch
   ```

## 无效尝试

- **** — Hides the symptom; the race still corrupts data nondeterministically. (95% 失败率)
- **** — Yielding does not create a happens-before relationship; race remains. (90% 失败率)
