# error：go vet：赋值复制了锁值：sync.WaitGroup 包含 sync.noCopy

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

## 根因

按值传递 sync.WaitGroup 会复制其内部状态；副本的 Done 不会影响原始的 Wait，导致 Wait 挂起或 panic。

## 版本兼容性

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

## 解决方案

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

## 无效尝试

- **** — The copy shares no state; Done on the copy doesn't decrement the original counter, so Wait blocks forever. (90% 失败率)
- **** — The state is still split across two structs; the mutex does not merge them. (85% 失败率)
