clickhouse-go

The official Go driver for ClickHouse, pairing a fast native protocol client with full database/sql compatibility.

Library
Go
vv2.48.0
3,335stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
94/100Excellent
Development Activity96
Maintenance96
Community84
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
88/100Excellent
Architecture88
Code Quality90
Innovation85
Learning Curve88

clickhouse-go is ClickHouse’s official Golang database driver, maintained by the ClickHouse team itself. It exposes two ways to talk to a ClickHouse server: a ClickHouse-specific driver.Conn interface (clickhouse.Open) that speaks the native wire protocol for maximum throughput, and a standard database/sql-compatible interface (clickhouse.OpenDB / sql.Open) for teams that want to reuse existing tooling, ORMs, and connection-pooling conventions.

Both interfaces work over TCP-native and HTTP transports, and the driver leans on ClickHouse’s own low-level ch-go client for column encoding, decoding, and compression. It covers the breadth of ClickHouse’s type system (including newer types like BFloat16, Dynamic, Variant, and geo types), supports bulk batch inserts, async inserts, connection pooling with failover/load balancing, structured logging via log/slog, JWT authentication, and OpenTelemetry-aware query context.

What You Get

  • A native driver.Conn interface (clickhouse.Open) using ClickHouse’s binary wire protocol for the fastest column-oriented reads and writes
  • A standard database/sql implementation (clickhouse.OpenDB) that works with existing Go database tooling, migration tools, and ORMs expecting the stdlib interface
  • Bulk batch insert support (PrepareBatch) and async inserts for high-throughput ingestion workloads
  • Connection pooling with configurable open strategies (in-order, round-robin, random) and automatic failover across multiple ClickHouse addresses
  • Broad ClickHouse type coverage — Decimal, Map, Array, Tuple, Nested, JSON, geo types, BFloat16, Dynamic, and Variant — with struct scanning/marshaling helpers
  • Structured logging via Go’s log/slog, JWT auth, LZ4/ZSTD/Brotli/GZIP compression, and OpenTelemetry-aware query context

Common Use Cases

  • Powering analytics dashboards and reporting services that query ClickHouse directly from Go backends
  • High-throughput event or log ingestion pipelines that batch-insert rows via the native protocol
  • Migrating an existing database/sql-based Go service onto ClickHouse without rewriting its data-access layer
  • Building internal tooling or CLIs that need typed access to ClickHouse-specific column types (JSON, geo, Dynamic/Variant)
  • Streaming query results or inserts in raw formats (CSV, JSONEachRow, Parquet) over HTTP for interop with external systems

Under The Hood

Architecture The driver is organized as a small set of layers rather than one monolithic client: the top-level clickhouse package exposes Open/OpenDB entry points that dispatch to one of two transport implementations — a native TCP path (conn.go, conn_pool.go, backed by an internal circular-queue connection pool with lifetime-based eviction) or an HTTP path (conn_http.go) — both implementing a shared internal transport interface so the rest of the driver is protocol-agnostic. Row/column encoding and the ClickHouse wire format live in lib/column and lib/proto, decoupled from connection handling, while lib/driver defines the public driver.Conn/driver.Batch contracts that both the native API and the database/sql adapter (clickhouse_std.go) implement against. This separation means the database/sql surface is a thin wrapper reusing the same dial/connect functions as the native client rather than a parallel implementation, so a change to the wire protocol only needs to happen once.

Tech Stack Built on Go 1.25 with the toolchain pinned in go.mod. Column encoding, decoding, and compression delegate to ClickHouse’s own low-level ch-go library rather than reimplementing the wire format locally. Compression support spans LZ4, ZSTD, GZIP, Deflate, and Brotli (andybalholm/brotli). Integration tests spin up real ClickHouse instances via testcontainers-go and Docker Compose rather than mocks. Additional dependencies cover OpenTelemetry tracing (go.opentelemetry.io/otel), geo types (paulmach/orb), arbitrary-precision decimals (shopspring/decimal), and UUID generation (google/uuid).

Code Quality The repository carries an extensive test suite — 259 _test.go files covering unit tests, benchmark tests, and fuzz tests (e.g. conn_http_errors_fuzz_test.go) built on testify assertions, alongside a tests/ directory of integration tests that run against live ClickHouse containers. CI (.github/workflows/) runs separate workflows for head-of-branch tests, ClickHouse Cloud tests, linting, and CodeQL static analysis, plus a docs-sync check that keeps the published documentation in step with the code. Error handling is explicit throughout, using sentinel errors.New values (ErrBatchInvalid, ErrConnectionClosed, etc.) and a typed OpError wrapper rather than bare error strings.

API Design The defining design choice is offering two API surfaces — a ClickHouse-native interface for performance-sensitive code and a database/sql-compatible one for drop-in use with existing Go tooling — built on the same underlying connection and encoding layers so neither is a second-class citizen. On top of that it exposes ClickHouse-specific ergonomics that a generic SQL driver wouldn’t: typed struct scanning/appending, batch-release-connection helpers, named/numeric/positional parameter binding, and direct support for ClickHouse’s more unusual types (Dynamic, Variant, LineString) without falling back to raw bytes.

Used by 19 apps in this directory

Go
52%
MIT

Bytebase

Devops

14,449

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
91
Repo Health
73
Technical
69
Dependency
Built with
Go52%
TypeScript39%
Updated yesterday
Go
63%
Apache 2.0

Coroot

Analytics · Monitoring

7,895

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
Go63%
Vue35%
Updated 3 days ago
Go
73%
Other

Flipt

Devops · Developer Tools

4,884

Git-native feature flag platform that stores, versions, and deploys feature toggles directly in your own Git repositories with no external database required.

View details
89
Repo Health
83
Technical
70
Dependency
Built with
Go73%
TypeScript26%
Updated yesterday
TypeScript
71%
Other

highlight.io

Developer Tools · Analytics · Monitoring

9,373

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
70
Repo Health
78
Technical
65
Dependency
Built with
TypeScript71%
Go16%
Updated 1 weeks ago
TypeScript
96%
MIT

HyperDX

Developer Tools · Analytics · Monitoring

9,870

Open source observability platform that unifies logs, traces, metrics, and session replays on ClickHouse — now the core of ClickStack.

View details
87
Repo Health
83
Technical
70
Dependency
Built with
TypeScript96%
Updated yesterday
TypeScript
56%
MIT

Jitsu

Data Engineering

5,056

Open-source, fully-scriptable data ingestion engine that streams events from web, apps, and APIs to any data warehouse in real time.

View details
89
Repo Health
79
Technical
67
Dependency
Built with
TypeScript56%
Go42%
Updated yesterday
Go
95%
MIT

Formance Ledger

Invoicing Finance · Developer Tools · Databases

1,368

The programmable open source core ledger for fintech — build money-moving applications with atomic multi-posting transactions, account-based modeling, and Numscript, a built-in DSL for financial logic.

View details
88
Repo Health
8
Technical
68
Dependency
Built with
Go95%
Updated 2 days ago
Go
96%
Other

Netmaker

Automation · Security

11,771

Automate secure WireGuard mesh networks from homelab to enterprise scale without manual configuration.

View details
92
Repo Health
79
Technical
71
Dependency
Built with
Go96%
Updated today
Go
98%
Apache 2.0

Nightingale

Monitoring

13,272

Open-source alerting engine that connects to any time-series or log data source and routes alarms to 20+ notification channels with AI-assisted triage.

View details
96
Repo Health
77
Technical
68
Dependency
Built with
Go98%
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