# fatal error: 所有 goroutine 都处于休眠状态 - 死锁！（WaitGroup 被复制）

- **ID:** `go/waitgroup-passed-by-value`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

sync.WaitGroup 按值传递给函数，导致 Add/Done 作用于副本，原对象的 Wait() 永远无法解除阻塞。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   func worker(wg *sync.WaitGroup) {
    defer wg.Done()
    // ...
}
   ```
2. **** (92% 成功率)
   ```
   type Pool struct { wg sync.WaitGroup }
func (p *Pool) Run() { p.wg.Add(1); go func(){ defer p.wg.Done() }() }
   ```

## 无效尝试

- **** — The copy bug remains; the timeout just papers over the deadlock without fixing counter propagation. (80% 失败率)
- **** — The counters are in different copies; adding to the original still does not match the copy's Done calls. (85% 失败率)
