pq is a Go PostgreSQL driver for database/sql.
The driver solves the problem of connecting Go applications to PostgreSQL databases by implementing the standard database/sql interface. It supports connection strings compatible with PostgreSQL's libpq, accepting both key=value and postgres:// URL formats, and allows runtime parameters like search_path and work_mem to be specified directly in the connection string. PostgreSQL errors are returned as structured pq.Error types that can be inspected for error codes and supplemented with detail and context information when available.
Developers should choose pq if they are building Go applications that need to interact with PostgreSQL and prefer a driver that integrates with the standard library's database/sql package. The driver supports all maintained PostgreSQL versions and provides authentication methods including PASSWORD, MD5, and SCRAM-SHA256 out of the box, with optional GSS/Kerberos support available through a separate module to avoid unnecessary dependencies. The tool is well-suited for applications requiring bulk data import via COPY statements, listening for database notifications through pq.Listener, or handling PostgreSQL-specific features like NOTICE messages through registered callbacks.
The project maintains a stable codebase with infrequent but deliberate updates. Pull requests receive careful review with discussion of implementation details and edge cases before acceptance. Issues are addressed thoughtfully, with maintainers providing detailed explanations of design decisions and occasionally declining requests that would add unnecessary complexity. The project prioritizes backward compatibility and avoids breaking changes, reflecting a mature approach to API stability.