# 警告：数据竞争
Goroutine 7 写入地址 0x00c0000b4010
主 goroutine 先前读取地址 0x00c0000b4010

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

## 根因

共享变量被不同 goroutine 无同步地读写。Go 内存模型不提供顺序保证，因此会出现撕裂读取和过期值。

## 版本兼容性

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

## 解决方案

1. **** (97% 成功率)
   ```
   var mu sync.Mutex
var counter int
mu.Lock()
counter++
mu.Unlock()
   ```
2. **** (96% 成功率)
   ```
   var counter atomic.Int64
counter.Add(1)
_ = counter.Load()
   ```

## 无效尝试

- **** — Hides the symptom; the underlying race can corrupt memory or produce wrong results silently. (92% 失败率)
- **** — Go has no volatile keyword; the compiler and CPU may still reorder accesses. (98% 失败率)
