# fatal error: all goroutines are asleep - deadlock! (WaitGroup)

- **ID:** `go/goroutine-leak-on-waitgroup`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

WaitGroup的计数器未归零，主goroutine调用Wait，但子goroutine因阻塞而无法完成。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.20 | active | — | — |

## Workarounds

1. **** (85% success)
   ```
   使用select和done通道通知退出
   ```
2. **** (90% success)
   ```
   ctx, cancel := context.WithCancel(context.Background()); go func(){ select { case <-ctx.Done(): return } }()
   ```

## Dead Ends

- **** — 超时后goroutine仍在运行，程序可能退出但资源泄漏。 (60% fail)
- **** — 关闭通道可能引发其他panic，且未解决阻塞原因。 (70% fail)
