# sql: 列索引 1 扫描错误：将 driver.Value 类型 []uint8 转换为 int64：无效转换

- **ID:** `go/database-sql-scan-type-error`
- **领域:** go
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

将数据库值扫描到不兼容类型的 Go 变量中，例如将字符串列扫描为整数。

## 版本兼容性

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

## 解决方案

1. **** (85% 成功率)
   ```
   var id int64; if err := rows.Scan(&id); err != nil { /* handle type mismatch */ }; // or scan into sql.NullString and convert
   ```

## 无效尝试

- **** — Fails at runtime if the value is not a string or []byte. (80% 失败率)
- **** — Leads to incorrect data handling and silent bugs. (90% 失败率)
