Go has two first-class ways to talk to SQLite:

  • mattn/go-sqlite3 — the CGO driver, wraps the real SQLite C library.
  • modernc.org/sqlite — a pure-Go translation of SQLite, no CGO.

Both work. I run the pure-Go one in production, and the reasons are operational, not benchmark-related. Let me be honest about the tradeoffs.

Why I chose modernc (pure Go)

  1. Builds anywhere, trivially. No C compiler required. go build just works on Linux, Windows, and cross-compiles with GOOS/GOARCH. The CGO driver needs gcc and cross-toolchains, which turn every deploy into a small adventure.
  2. One less class of build failure. CGO adds C compilation, link flags, and platform quirks. For a single-binary service I want go build to be boring and repeatable.
  3. Static binaries. No need to ship or locate the C SQLite library on the target. Copy one binary, done.
  4. It is real SQLite. modernc is a faithful translation of the C code, not a different engine. Compatibility is a non-issue for the features I use (WAL, VACUUM INTO, PRAGMAs).

The honest tradeoffs

  • Speed: modernc has historically been a bit slower than the CGO wrapper on some workloads. If your database is your hot path at high volume, benchmark your workload — do not trust a generic table.
  • Familiarity: the CGO driver is older and more battle-tested by volume. modernc is now widely deployed too.
  • Resource use: pure-Go translation can use more memory in some cases. Again — measure yours.

How I actually decided

I ran the same service with both drivers. For a typical web service doing moderate reads and writes, the difference did not move the needle. What did move it: the pure-Go driver deleted an entire class of build-and-deploy pain. A day of toolchain fighting is worth more than a few microseconds per query.

My advice: if you are on a team that already has a C toolchain and you need every drop of performance, mattn/go-sqlite3 is a fine choice. If you value boring builds and easy deployment — and most services do not need the last few percent — start with modernc.org/sqlite and measure before you switch.

Estimating the size of the database you are about to store with your driver of choice? The estimator below is driver-agnostic.

Estimated database size436.2 MB
Raw data + indexes370.0 MB
Approx. pages (4 KiB)111662