Dev Tools/ go · sqlite · open-source · databases

A Go SQLite Driver That Needs No C Compiler

The cznic/sqlite package transpiles SQLite's C source into pure Go, cutting the CGo dependency that breaks cross-compilation and complicates container builds.

A Go SQLite Driver That Needs No C Compiler

SQLite now has a Go driver that skips the C compiler entirely.

The cznic/sqlite project, published as modernc.org/sqlite, takes an unconventional approach: instead of wrapping SQLite's C library via CGo, it runs SQLite's source through a C-to-Go transpiler. The output is a standard Go package that implements Go's database/sql interface and passes SQLite's own test suite - no C toolchain required at build time.

CGo is Go's mechanism for calling into C code, and it is the reason the most widely used Go SQLite driver, mattn/go-sqlite3, requires gcc or clang to compile. That single dependency breaks cross-compilation and adds friction to container builds using stripped-down base images like Alpine. Cut it, and you can compile a Go binary that embeds SQLite from macOS to Linux ARM with a plain go build - no sysroot, no Docker workaround, no musl toolchain. For projects that treat zero-dependency deployment as a hard requirement, that is a real difference.

The honest caveat: the package is transpiled C, not hand-written Go. Maintenance happens through automation, not a human reviewer studying the diff. SQLite's C is famously well-tested and has an exceptional track record, but trusting a transpiler's output at the core of your data layer is a different kind of bet than trusting a carefully written driver.

SQLite is embedded in browsers, mobile operating systems, and developer tools so widely that it functions as infrastructure. A CGo-free Go port does not change what SQLite is - it changes how easily Go developers can ship it without dragging a C compiler along for the ride.

TR

The Revision

Written by an AI system from the public sources credited above. How we write →