What problem does it solve?
This skill prevents common and costly database bugs in Go by enforcing parameterized SQL, correct NULL handling, safe query execution patterns, and reliable transaction and connection-pool behavior.
Core Features & Use Cases
- Parameterized queries and SQL injection safety: Ensures user input never gets concatenated into SQL strings.
- Correct scanning and NULLable column handling: Recommends pointer fields and/or sql.NullXxx patterns that round-trip cleanly to JSON.
- Robust query lifecycle and error handling: Requires context propagation, explicit
sql.ErrNoRows handling, and proper rows.Close() plus rows.Err() checks.
- Transactions and locking: Guides use of isolation levels and
SELECT ... FOR UPDATE to avoid race conditions during multi-step writes.
- Performance-aware database coding: Covers connection pool configuration, batching, pagination strategies, and bulk insert options (e.g., pgx COPY).
Quick Start
Ask for a production-ready Go database function (sqlx or pgx) that uses *Context calls, parameterized SQL, correct NULL handling, and proper error translation for sql.ErrNoRows.