# fatal error: 所有 goroutine 都休眠了 - 死锁！(向 nil channel 发送)

- **ID:** `go/send-on-nil-channel-blocks`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

向 nil channel 发送或接收会永久阻塞。如果所有 goroutine 都这样，运行时会报告死锁。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   ch := make(chan int)
   ```
2. **** (85% 成功率)
   ```
   if ch == nil { return }
ch <- v
   ```

## 无效尝试

- **** — Default turns a blocking send into a busy-loop or dropped message, not a fix for the nil channel. (70% 失败率)
- **** — More goroutines blocked on nil channel just produce the same deadlock. (85% 失败率)
