# 恐慌：从已关闭的通道接收（返回零值）

- **ID:** `go/channel-receive-from-closed`
- **领域:** go
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

从已关闭的通道接收会立即返回零值，如果处理不当可能导致逻辑错误。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Use the two-value receive form: v, ok := <-ch; if !ok { /* channel closed */ }
   ```
2. **** (90% 成功率)
   ```
   Use a done channel to signal closure and avoid receiving from closed channels.
   ```

## 无效尝试

- **** — The zero value may be indistinguishable from real data, causing incorrect behavior. (80% 失败率)
- **** — This may skip important data or break the program's flow. (60% 失败率)
- **** — The boolean is only available in the two-value receive form; if not used, it's missed. (50% 失败率)
