# panic: sync: WaitGroup 在上一次 Wait 返回前被重用

- **ID:** `go/waitgroup-misuse-reused-before-wait`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在上一次 Wait 尚未返回时（另一 goroutine）就再次 Add，违反了 Add 必须先于 Wait 的规则。

## 版本兼容性

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

## 解决方案

1. **** (94% 成功率)
   ```
   Use a fresh WaitGroup per batch instead of reusing one:
for _, batch := range batches {
    var wg sync.WaitGroup
    for _, x := range batch { wg.Add(1); go func(x T){ defer wg.Done(); work(x) }(x) }
    wg.Wait()
}
   ```

## 无效尝试

- **** — Timing-based synchronization is nondeterministic and the panic can still occur under load. (85% 失败率)
