pg
go-pg is a PostgreSQL client and ORM for Go that emphasizes PostgreSQL-specific features and performance. The project is in maintenance mode with only critical issues addressed; the maintainers recommend new projects use Bun, which offers similar functionality across multiple databases.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | go-pg/pg |
| Owner | go-pg |
| Primary language | Go |
| License | BSD-2-Clause — OSI-approved |
| Stars | 5.8k |
| Forks | 413 |
| Open issues | 121 |
| Latest release | v10.15.1 (2026-05-29) |
| Last updated | 2026-05-29 |
| Source | https://github.com/go-pg/pg |
What pg is
go-pg provides struct-based ORM mapping, support for PostgreSQL types (arrays, hstore, JSONB, composite types), connection pooling with circuit breaker, transactions, prepared statements, and bulk operations. It includes relationship support (has-one, belongs-to, has-many, many-to-many) and can generate schema from structs.
Get the pg source
Clone the repository and explore it locally.
git clone https://github.com/go-pg/pg.gitcd pg# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- All struct fields are nullable by default; use `pg:"notnull"` and `pg:"use_zero"` tags carefully to align Go zero-value semantics with SQL constraints.
- Relationship loading (has-one, belongs-to, has-many, many-to-many) requires explicit `.Relation()` calls; N+1 queries are possible if not managed deliberately.
- The library supports transactions and context-based cancellation; ensure timeout and context-cancellation patterns are consistently applied in error-prone code paths.
- Bulk operations (insert, update, delete) are available; verify performance gains via profiling before assuming they're faster than single-row operations for your workload.
- Schema generation from structs is supported but review generated DDL for production use; rely on migrations for version control and audit trails.
When to avoid it — and what to weigh
- Multi-database strategy required — If your roadmap includes MySQL, MariaDB, or SQLite, go-pg is PostgreSQL-only. Bun (the recommended successor) supports all four and should be evaluated instead.
- New project starting today — The README explicitly states go-pg is in maintenance mode and recommends Bun for new development. Choosing go-pg for a greenfield project introduces technical debt and limits future flexibility.
- Rapid feature velocity needed — Only critical issues are addressed in maintenance mode. If you need regular ORM improvements, query optimization features, or framework integrations, an actively developed ORM is more appropriate.
- Uncertainty about PostgreSQL commitment — If your database choice is not yet finalized or subject to change, the single-database focus makes go-pg risky. Use an ORM with multi-database support or defer ORM selection.
License & commercial use
BSD-2-Clause (Simplified License). This is an OSI-approved permissive license that permits commercial use, modification, and distribution with minimal restrictions (retain copyright notice and license text).
BSD-2-Clause is permissive and explicitly allows commercial use without royalties or restrictions. No secondary licenses detected. Suitable for closed-source and proprietary products. Consult legal counsel if integrating other dependencies with conflicting licenses.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Moderate |
| Documentation | Adequate |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
Parameterized queries and prepared statements are available and should be used consistently. Context-based timeout support mitigates slowloris and resource-exhaustion risks. No known advisories mentioned in provided data. Review generated schema DDL before production deployment. Ensure network isolation and TLS configuration for PostgreSQL connections in security-critical environments. Circuit breaker and retry logic may mask transient failures; monitor for partial failures.
Alternatives to consider
Bun
Official successor with same design philosophy but multi-database support (PostgreSQL, MySQL, MariaDB, SQLite). Actively developed. Recommended by go-pg maintainers for new projects.
sqlc
Type-safe SQL code generation from schema. Avoids ORM overhead and forces explicit query design. Suitable if you prefer hand-tuned SQL and compile-time safety over convenience.
GORM
Most popular Go ORM. Multi-database support, large community, frequent updates. More feature-rich but higher learning curve and potential over-abstraction.
Build on pg with DEV.co software developers
go-pg is stable for existing deployments but in maintenance mode. Confirm whether Bun or another ORM better fits your multi-database strategy and feature roadmap.
Talk to DEV.coRelated on DEV.co
Explore the category and the services that help you build with it.
pg FAQ
Is go-pg still actively developed?
Can I use go-pg with MySQL or SQLite?
How does go-pg handle NULL values?
Does go-pg support migrations?
Custom software development services
DEV.co is a software development agency delivering custom software development services to companies building on open source. Our software developers and web developers design, integrate, and ship production systems — spanning web development, APIs, AI, data, and cloud. If pg is part of your open-source databases roadmap, our team can implement, customize, migrate, and maintain it.
Evaluating a PostgreSQL ORM for Go?
go-pg is stable for existing deployments but in maintenance mode. Confirm whether Bun or another ORM better fits your multi-database strategy and feature roadmap.