1---2name: li-lance-android-seraphim-framework-golang-database3description: Golang Database4---56# Golang Database78## **Priority: P0 (CRITICAL)**910## Principles1112- **Prefer Raw SQL/Builders over ORMs**: `sqlc` generates type-safe Go from SQL. ORMs (GORM) can13 obscure performance.14- **Repository Pattern**: Abstract DB access behind interfaces in `internal/port/`.15- **Connection Pooling**: Always configure pool settings.16- **Transactions**: ACID logic must use transactions. Pass `context.Context` everywhere.1718## Implementation Workflow19201. **Choose driver** — PostgreSQL: `pgx/v5`; MySQL: `go-sql-driver/mysql`; SQLite:21 `modernc.org/sqlite`.222. **Configure pool** — Set `MaxOpenConns`, `MaxIdleConns`, and `ConnMaxLifetime` on the connection.233. **Define repository interface** — Abstract DB access behind an interface at the consumer side.244. **Use context-aware queries** — Always use `QueryContext`/`ExecContext`; bare queries ignore25 timeouts.265. **Close rows** — Always `defer rows.Close()` and check `rows.Err()` after iteration.276. **Wrap in transactions** — Use transactions for multi-step operations requiring atomicity.2829See [repository pattern and connection pool examples](references/repository-pattern.md)3031## Anti-Patterns3233- **No global db var**: Inject DB connection via constructor.34- **No context-less queries**: Use `QueryContext`/`ExecContext`; bare queries ignore timeouts.35- **No leaked rows**: Always `defer rows.Close()` and check `rows.Err()`.3637## References3839- [Repository Pattern Implementation](references/repository-pattern.md)40- [Connection Tuning](references/connection-tuning.md)4142---43> Source: [li-lance/android-seraphim-framework](https://github.com/li-lance/android-seraphim-framework) — distributed by [TomeVault](https://tomevault.io).44<!-- tomevault:4.0:skill_md:2026-06-16 -->
Run npx skillmds@latest add tomevault-io/li-lance-android-seraphim-framework-golang-database in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Golang Database It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.