Skip to content

Go

github.com/potluckdb/potluckdb-go/sqlite3 is a drop-in replacement for go-sqlite3 that runs on PotluckDB’s build of SQLite. It works on Linux (glibc 2.28+ and musl), macOS 11+ and Windows, x64 and ARM64.

Terminal window
go get github.com/potluckdb/potluckdb-go/sqlite3
import (
"database/sql"
_ "github.com/potluckdb/potluckdb-go/sqlite3" // was: _ "github.com/mattn/go-sqlite3"
)
db, err := sql.Open("sqlite3", "app.db")

The rest of your code stays the same: the driver name sqlite3, connection string options, types, errors and build tags are go-sqlite3’s (1.14.52). As with go-sqlite3, cgo must be on and a C compiler installed (on Windows, MinGW-w64: see below), but nothing of SQLite is compiled: the first build takes seconds instead of a minute.

To keep your code, and to switch dependencies that import go-sqlite3 too (for example GORM’s SQLite driver), add one replace line to go.mod:

Terminal window
go mod edit -replace github.com/mattn/go-sqlite3=github.com/potluckdb/potluckdb-go/sqlite3@v0.8.0-dev.2
go mod tidy
  • On Alpine and other musl systems, build with -tags musl; a build with the wrong setting stops with a message saying what to do.
  • On Windows, use a MinGW-w64 C compiler for Microsoft’s UCRT runtime, for example llvm-mingw or MSYS2’s UCRT64, CLANG64 or CLANGARM64. A compiler for the older MSVCRT runtime works too, with the same results (tested: GCC 16.2 from WinLibs, x64).
  • go mod tidy and go mod download fetch the library for every platform; go build and go test use only your platform’s.
  • Databases sync in a later pre-release; for now it runs queries exactly like go-sqlite3.

All the details: go/README.md.