# io: 在已关闭的管道上读写

- **ID:** `go/io-writer-closed`
- **领域:** go
- **类别:** io_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

尝试在已关闭的 io.Pipe 上进行读取或写入。

## 版本兼容性

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

## 解决方案

1. **** (80% 成功率)
   ```
   pr, pw := io.Pipe(); defer pw.Close(); // ensure proper close order
   ```
2. **** (90% 成功率)
   ```
   Use sync.Once to close the pipe only once
   ```

## 无效尝试

- **** — Leads to data corruption or panic (100% 失败率)
- **** — Cannot reopen a closed pipe; need to create a new one (100% 失败率)
