# 错误：读取 /dev/urandom：期望1024字节，实际512字节

- **ID:** `go/io-read-write-count-mismatch`
- **领域:** go
- **类别:** io_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

io.Reader 返回的字节数少于请求数且未返回错误，违反了 io.Reader 契约。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Use io.ReadFull to ensure the exact number of bytes are read.
   ```
2. **** (90% 成功率)
   ```
   Loop over io.Read until the desired count is reached or an error occurs.
   ```

## 无效尝试

- **** — This leads to data corruption and undefined behavior. (95% 失败率)
- **** — The buffer size doesn't affect the reader's behavior; it may still return short reads. (80% 失败率)
