# sql：Scan 错误，列索引 2 名称 "email"：不支持将 NULL 转换为 string

- **ID:** `go/sql-converting-null-to-string`
- **领域:** go
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

向非指针 string 扫描可空列。NULL 无法赋给 string。

## 版本兼容性

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

## 解决方案

1. **** (92% 成功率)
   ```
   var email sql.NullString
err := row.Scan(&email)
if email.Valid { u.Email = email.String }
   ```
2. **** (88% 成功率)
   ```
   Use a pointer *string for nullable columns.
   ```

## 无效尝试

- **** — Loses the distinction between empty and NULL. (60% 失败率)
- **** — Requires type assertion and is error-prone. (65% 失败率)
