go
data_error
ai_generated
true
error: sql: expected 0 arguments, got 1
ID: go/database-sql-prepare-query-error
80%Fix Rate
84%Confidence
0Evidence
2026-02-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.20 | active | — | — | — |
| 1.21 | active | — | — | — |
Root Cause
Providing arguments to a query that has no placeholders, or mismatched placeholders in the SQL statement.
generic中文
向没有占位符的查询提供参数,或SQL语句中的占位符不匹配。
Workarounds
-
95% success Always use parameterized queries with correct placeholder count
query := "SELECT * FROM users WHERE id = ?" rows, err := db.QueryContext(ctx, query, userID)
Dead Ends
Common approaches that don't work:
-
Adding placeholders without verifying SQL
60% fail
May introduce SQL injection risk; use parameterized queries correctly.