What problem does it solve?
This Skill provides comprehensive guidance and practical examples for interacting with SQL databases in Go, covering everything from basic queries to advanced patterns like connection pooling, transaction management, and schema migrations.
Core Features & Use Cases
- Database Library Selection: Guides you in choosing between
database/sql, sqlx, and pgx based on your needs.
- Repository Pattern: Demonstrates how to implement an interface-based repository pattern for testable and maintainable data access.
- Migrations: Explains how to use
golang-migrate for robust database schema versioning.
- Transaction Handling: Covers safe transaction management, isolation levels, and retry logic.
- Use Case: When building a new Go web service that requires a PostgreSQL backend, use this Skill to set up your database connection, implement user data CRUD operations using
sqlx, and manage your schema with golang-migrate.
Quick Start
Use the golang-database-patterns skill to set up a connection pool using pgx and implement a user repository with Create, GetByID, and Update methods.