golang-database

Enforce parameterized queries and lifecycle management in Go database code.

1|Updated May 27, 2026
One-click install
npx skills add https://github.com/dmwin72015/netdisk --skill golang-database-dmwin72015
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-database
Source: https://github.com/dmwin72015/netdisk/tree/main/.agents/skills/golang-database
Command: npx skills add https://github.com/dmwin72015/netdisk --skill golang-database-dmwin72015

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It prevents common, production-grade database mistakes in Go by guiding developers to write safe, parameterized, context-aware SQL code with correct error handling and resource management.

Core Features & Use Cases

  • Parameterized queries over string-built SQL: protects against SQL injection when implementing filters, sorting, and dynamic conditions.
  • Correct scanning and NULL handling: models NULLable columns with pointer fields or explicit strategies, ensuring structs and JSON behave predictably.
  • Robust lifecycle management: enforces proper context propagation, explicit sql.ErrNoRows handling, correct rows.Close(), rows.Err() checks, and safe transaction patterns with SELECT ... FOR UPDATE.
  • Operational performance guardrails: recommends batching, cursor pagination, and connection-pool configuration while explicitly avoiding hidden SQL features and ORM pitfalls.
  • Migrations with tooling, not AI-generated SQL: directs teams to use migration tools (e.g., golang-migrate) and to review schema changes with production awareness.

Quick Start

Use the golang-database skill to review or generate Go repository code that uses sqlx/pgx for PostgreSQL with fully parameterized queries, context propagation, correct NULL handling, and safe transaction boundaries.

Frequently Asked Questions about golang-database

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent SQL injection in Go when building dynamic queries with sqlx or pgx?▼

Prevent SQL injection in Go by enforcing parameterized queries over string-built SQL when implementing filters, sorting, and dynamic conditions in database/sql, sqlx, or pgx repository code.

What is the best way to handle NULLable columns when scanning rows in Go PostgreSQL code?▼

Handle NULLable columns in Go by modeling them with pointer fields or explicit strategies, ensuring your structs and JSON behave predictably when scanning rows from PostgreSQL.

How do I manage database transactions and context propagation correctly in Go?▼

Manage Go database transactions correctly by enforcing context propagation via *Context APIs, proper rows.Close and rows.Err checks, and safe transaction patterns like SELECT ... FOR UPDATE.

Does this guidance require using an ORM for PostgreSQL access in Go?▼

No, this guidance explicitly recommends avoiding ORM pitfalls and hidden SQL features, directing developers to write safe, explicit SQL using database/sql, sqlx, or pgx for PostgreSQL.

Why do I need to handle sql.ErrNoRows explicitly in Go database repository code?▼

You must handle sql.ErrNoRows explicitly to distinguish between a true error and an empty query result, which prevents production-grade database bugs and ensures robust lifecycle management in Go.

What are the limitations of using AI-generated SQL for database migrations in Go?▼

AI-generated SQL lacks production awareness for migrations, so you should use migration tools like golang-migrate to review schema changes and avoid operational database mistakes.