# sql：未知驱动 "postgres"（是否忘记导入？）

- **ID:** `go/sql-driver-unknown`
- **领域:** go
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

未以空白导入方式导入数据库驱动包，database/sql 没有已注册的驱动。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   import (
  "database/sql"
  _ "github.com/lib/pq"
)
db, _ := sql.Open("postgres", dsn)
   ```
2. **** (90% 成功率)
   ```
   Use pgx/v5/stdlib blank import when using pgx driver.
   ```

## 无效尝试

- **** — Named imports can trigger 'imported and not used' unless referenced. (60% 失败率)
- **** — Only changes the error message. (90% 失败率)
