# WARNING: DATA RACE
由 goroutine N 在 0x... 读取：
  main.main.func1()
由 goroutine M 在 0x... 先前写入：

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

## 根因

多个 goroutine 在无同步的情况下读写共享变量，race detector 报告了冲突访问。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   var counter int64
atomic.AddInt64(&counter, 1)
   ```
2. **** (93% 成功率)
   ```
   var mu sync.Mutex
mu.Lock()
counter++
mu.Unlock()
   ```

## 无效尝试

- **** — Hides the symptom but the underlying race still corrupts data and can crash in production. (90% 失败率)
- **** — unsafe does not provide synchronization; the race remains. (85% 失败率)
