# 致命错误：所有 goroutine 都处于休眠状态 - 死锁！

- **ID:** `go/deadlock-unbuffered-channel-single-goroutine`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在没有接收方的同一 goroutine 中向无缓冲通道发送数据会永久阻塞，导致死锁。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   ch := make(chan int)
go func() { ch <- 42 }()
value := <-ch
fmt.Println(value)
   ```
2. **** (90% 成功率)
   ```
   ch := make(chan int, 1)
ch <- 42
fmt.Println(<-ch)
   ```

## 无效尝试

- **** — Only works if the sender doesn't need to wait for a receiver; if the buffer fills, the same deadlock occurs. (70% 失败率)
- **** — Sleeping doesn't create a receiver; the goroutine still blocks indefinitely. (90% 失败率)
- **** — The program terminates immediately; no recovery is possible. (100% 失败率)
