agentsclimarketplace

Golang database

Skill ComeOnOliver/skillshub/skills/HoangNguyen0403/agent-skills-standard/golang-database

🧠 The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.

Install
npx -y skills add ComeOnOliver/skillshub --skill golang-database

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

Standards for database interaction, connection pooling, and repository patterns in Golang. Use when implementing database access, connection pools, or repositories in Go. (triggers: internal/adapter/repository/**, database, sql, postgres, gorm, sqlc, pgx)

SKILL.md

1.4 KB, as published. Nobody here has run it

Golang Database Standards

Priority: P0 (CRITICAL)

Principles

  • Prefer Raw SQL/Builders over ORMs: Go structs map well to SQL. ORMs (GORM) can obscure performance. Recommended: sqlc (type-safe SQL generation).
  • Repository Pattern: Abstract DB access behind interfaces in internal/port/ (e.g., UserRepository).
  • Connection Pooling: Always configure SetMaxOpenConns, SetMaxIdleConns, SetConnMaxLifetime.
  • Transactions: Logic requiring ACID MUST use transactions. Pass context.Context everywhere.

Drivers

  • PostgreSQL: jackc/pgx (Prefer pgx/v5 for performance and features).
  • MySQL: go-sql-driver/mysql.
  • SQLite: mattn/go-sqlite3 or modernc.org/sqlite (pure Go).

Anti-Patterns

  • No global db var: Inject DB connection via constructor; never use var db *sql.DB.
  • No bare queries: Use QueryContext/ExecContext; bare queries ignore context timeouts.
  • No leaked rows: Always defer rows.Close() and check rows.Err() after iteration.

References

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.