# 致命错误: 所有 goroutine 都处于休眠状态 - 死锁!（空 select{}）

- **ID:** `go/select-no-cases-blocks-forever`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

空 select{} 永久阻塞 goroutine。若为主 goroutine 且无其他进度，运行时会报告死锁。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   Block on a signal channel instead of empty select:

quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt)
<-quit
   ```
2. **** (92% 成功率)
   ```
   Use sync.WaitGroup to wait for real work completion:

wg.Wait()
   ```

## 无效尝试

- **** — Still blocks; program never exits and deadlock detection is defeated. (70% 失败率)
- **** — Goroutine leaks and main may exit before work completes. (60% 失败率)
