pq

A pure Go PostgreSQL driver for Go's standard database/sql package.

Library
Go
vv1.12.3
9,936stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
72/100Good
Development Activity72
Maintenance44
Community72
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture84
Code Quality85
Innovation82
Learning Curve80

lib/pq is a mature, pure-Go PostgreSQL driver that plugs directly into Go’s standard library database/sql interface. Registering it with a blank import lets you open a postgres connection and run queries with the same API you would use for any other SQL database, with no cgo or external C bindings required.

Beyond the basics it covers the parts of the PostgreSQL wire protocol that real applications need: TLS/SSL connections, PASSWORD/MD5/SCRAM-SHA-256 (and optional Kerberos) authentication, high-throughput COPY FROM STDIN bulk imports, asynchronous LISTEN/NOTIFY notifications, array and hstore type support, and libpq-compatible connection strings in both key=value and URL form.

What You Get

  • A drop-in postgres driver for database/sql, registered with a single blank import.
  • libpq-compatible connection strings in key=value and postgres:// URL form, including any run-time parameter.
  • Built-in TLS/SSL plus PASSWORD, MD5, and SCRAM-SHA-256 authentication (Kerberos via a separate module).
  • Bulk data loading through COPY FROM STDIN and asynchronous LISTEN/NOTIFY via pq.Listener.
  • Rich typed error values (pq.Error) exposing SQLSTATE codes, detail, hint, and source context.

Common Use Cases

  • Connecting a Go web service or API server to a PostgreSQL database through database/sql.
  • Streaming large datasets into PostgreSQL efficiently with COPY bulk imports.
  • Building event-driven features on top of PostgreSQL LISTEN/NOTIFY notifications.
  • Handling PostgreSQL-specific errors precisely by inspecting SQLSTATE codes.

Under The Hood

Architecture — pq is organized as a flat root package implementing the database/sql/driver contract, with conn.go handling the connection lifecycle and message loop, connector.go exposing the modern driver.Connector/Config path, copy.go implementing COPY-protocol streaming, notify.go providing the pq.Listener notification loop, and encode.go/array.go handling type encoding; supporting concerns are split into subpackages such as oid (type OIDs), scram (SCRAM-SHA-256), pqerror (SQLSTATE codes), hstore, and auth/kerberos, keeping optional dependencies out of the core.

Tech Stack — Written in pure Go (targeting go 1.23 per go.mod) with zero third-party runtime dependencies, relying solely on the standard library’s database/sql, crypto/tls, and net packages to speak the PostgreSQL wire protocol directly rather than binding to libpq via cgo.

Code Quality — The project is well tested, with 17 _test.go files covering connections, the connector, arrays, encoding, errors, COPY, SSL, and notifications, plus fuzz tests and runnable examples; tests execute against a real PostgreSQL instance (Docker compose provided) and the codebase carries typed error values and extensive doc comments.

API Design — The public surface is intentionally minimal and idiomatic: most users interact only through database/sql after a blank import, with pq.Config/NewConnectorConfig, pq.Listener, and pq.Error available for advanced needs. Package-level documentation in doc.go is thorough, and the libpq-compatible connection strings make the driver approachable for anyone familiar with PostgreSQL.

Used by 39 apps in this directory

Go
60%
Apache 2.0

Apache Answer

Community

15,652

Open-source Q&A platform for communities, help centers, and knowledge bases with AI assistant and plugin extensibility

View details
85
Repo Health
78
Technical
69
Dependency
Built with
Go60%
TypeScript36%
Updated 2 days ago
Go
85%
Apache 2.0

Argo Workflows

Devops · Data Engineering

16,916

The most popular Kubernetes-native workflow engine for orchestrating containerized DAGs, ML pipelines, CI/CD, and parallel batch jobs at scale.

View details
96
Repo Health
90
Technical
70
Dependency
Built with
Go85%
TypeScript11%
Updated today
Go
55%
Apache 2.0

Authgear

Authentication

1,989

Open-source, self-hostable authentication platform with passkeys, biometric login, SSO, MFA, and GraphQL admin API — a full Auth0/Clerk/Firebase alternative for SaaS and mobile apps.

View details
88
Repo Health
81
Technical
72
Dependency
Built with
Go55%
HTML26%
TypeScript17%
Updated yesterday
Go
82%
AGPL 3.0

Beta9

Developer Tools · AI Development · Data Engineering

1,746

Run AI workloads at scale with a Pythonic serverless runtime that handles GPU inference, background jobs, and sandboxes with zero infrastructure overhead.

View details
85
Repo Health
78
Technical
69
Dependency
Built with
Go82%
Python17%
Updated today
Go
52%
MIT

Bytebase

Devops

14,396

An open-source database CI/CD and DevSecOps platform — schema migration review, GitOps-driven changes, data masking, and access control across MySQL, PostgreSQL, Oracle, Snowflake, MongoDB, and more.

View details
92
Repo Health
73
Technical
69
Dependency
Built with
Go52%
TypeScript39%
Updated today
Go
76%
AGPL 3.0

Coder

Devops · Developer Tools · Code Editors

14,199

Self-hosted cloud development environments and AI coding agents — defined in Terraform, connected via WireGuard, automatically shut down when idle.

View details
93
Repo Health
90
Technical
71
Dependency
Built with
Go76%
TypeScript22%
Updated today
Go
72%
Other

Convoy

Developer Tools · Devops

2,858

Convoy is an open-source, cloud-native webhooks gateway that ingests events over HTTP or straight from Kafka, SQS, Google Pub/Sub, and RabbitMQ, then reliably delivers them to subscriber endpoints with signed payloads, automatic retries, circuit breaking, and JavaScript-based transformations.

View details
89
Repo Health
81
Technical
68
Dependency
Built with
Go72%
TypeScript14%
HTML13%
Updated yesterday
Go
62%
Apache 2.0

Coroot

Analytics · Monitoring

7,877

eBPF-powered observability with AI root cause analysis — zero code changes required, full-stack visibility out of the box.

View details
88
Repo Health
80
Technical
65
Dependency
Built with
Go62%
Vue36%
Updated yesterday
Go
79%
Apache 2.0

Dolt

Databases · Data Engineering · Developer Tools

24,221

The SQL database you can branch, merge, diff, and clone — Git for your data, MySQL-compatible and ready for multi-agent AI workflows.

View details
91
Repo Health
9
Technical
72
Dependency
Built with
Go79%
Shell20%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search