go-database

Review Go database code for SQL injection, context, and transaction safety.

8|Updated Jun 5, 2026
One-click install
npx skills add https://github.com/muratmirgun/gophers --skill go-database-muratmirgun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-database
Source: https://github.com/muratmirgun/gophers/tree/main/skills/go-database
Command: npx skills add https://github.com/muratmirgun/gophers --skill go-database-muratmirgun

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you write, review, and debug Go code that talks to SQL databases without falling into common production traps like SQL injection, leaked connections, missing context propagation, and unsafe transaction handling.

Core Features & Use Cases

  • Library selection: Choose between database/sql, sqlx, sqlc, pgx, and when to avoid ORMs like GORM or ent.
  • Query safety and correctness: Use parameterized queries, handle dynamic IN clauses and sortable columns safely, and distinguish not-found cases from real errors.
  • Operational reliability: Close rows, tune connection pools, manage NULL scanning, and structure transactions with proper isolation and locking.
  • Use case: Reviewing a repository layer that reads users from PostgreSQL and updating it to use context-aware queries, safe scans, and transaction-safe write logic.

Quick Start

Ask the assistant to review your Go database code for SQL injection risks, missing context usage, row-closing bugs, and transaction safety issues.

Frequently Asked Questions about go-database

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

FAQPage Schema
How do I prevent SQL injection in Go database code?

Prevent SQL injection in Go database code by enforcing parameterized queries and safe dynamic IN clause construction. This Skill guides SQL query building across libraries like database/sql, sqlx, sqlc, and pgx to eliminate injection risks.

How do I handle NULL values when scanning rows in Go?

Handle NULL values when scanning rows in Go by applying NULL-safe scanning techniques. This Skill ensures your repository code correctly manages NULL database values alongside explicit rows.Err checks to prevent runtime panics.

What is the best way to manage transactions and connection pools in Go?

Manage transactions and connection pools in Go by structuring transactions with proper isolation and locking while tuning connection pool parameters. This Skill prevents leaked connections and ensures reliable database access.

How do I use context-aware queries with database/sql in Go?

Use context-aware queries with database/sql in Go by passing context variables to query execution methods. This Skill updates repository layers to use context-aware I/O, ensuring operations can be cancelled and timed out correctly.

When should I choose pgx over sqlx or sqlc for Go database access?

Choose pgx over sqlx or sqlc when you need specialized PostgreSQL driver performance, whereas sqlx offers convenience and sqlc provides type-safe generation. This Skill helps select the right library and avoid ORMs like GORM.