# 返回值过多
	有 (T, error)
	想要 (T)

- **ID:** `go/too-many-return-values`
- **领域:** go
- **类别:** compile_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

期望单个返回值的函数被赋值或用于调用多返回值函数的位置，通常是由于函数签名不匹配或缺少错误处理。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| go1.20 | active | — | — |
| go1.21 | active | — | — |
| go1.22 | active | — | — |

## 解决方案

1. ```
   Assign both return values to variables and handle the error: val, err := someFunc(); if err != nil { ... }
   ```
2. ```
   If the function should return only one value, wrap it in a helper: func wrapper() T { val, _ := someFunc(); return val }
   ```

## 无效尝试

- **Adding an underscore to ignore the error: val, _ := someFunc()** — This only works if the caller expects two values; if the caller expects one, the compile error persists. (90% 失败率)
- **Changing the function signature to remove the error return** — Modifying the library function breaks its contract and may cause other compilation errors. (95% 失败率)
- **Using a type assertion on the result** — Type assertion cannot reduce the number of return values; it only works on interfaces. (98% 失败率)
