sqlc
SQL to type-safe code, rewritten in Go+
Current release —
v1.0.3.goforge.dev/gpsqlcis a Go+ reimplementation ofsqlc-dev/sqlcv1.31.1 whose compiler core is authored in Go+, producingsqlc generateoutput byte-identical to upstream. The installable artifact is stillsqlc— install withgo install goforge.dev/gpsqlc/cmd/sqlc@v1.0.3. The current line usesstd/parsecfor query annotations and consumes Go+ stdlib v0.207.0.
GoForge sqlc targets sqlc-dev/sqlc v1.31.1. It compiles SQL schemas and
queries into type-safe Go (and Kotlin/Python) across the PostgreSQL, MySQL, and
SQLite engines — and its hand-written compiler is now Go+.
Parity
sqlc version reports v1.31.1 and sqlc generate is byte-identical to
the pinned upstream binary. The golden-file endtoend suite — TestReplay,
886 fixture subtests spanning postgresql/mysql/sqlite × Go/Kotlin/Python —
passes, alongside the compiler, codegen, config, SQL-analysis, and CLI suites.
Go+ authorship
sqlc is a large compiler (~139k lines, most of it machine-generated SQL parsers
and protobuf). The hand-written core is authored in Go+ — 396 .gp files
across internal/{config, compiler, codegen, sql (ast/catalog/rewrite/validate), cmd} and pkg. The generated code (the ANTLR SQL parsers, the .pb.go
protobuf, the engine ASTs) stays hand-off Go, exactly as it was machine-produced
— it is not authored. Generation is deterministic and goplus gen -check is
clean against released goplus v0.139.0, which handled the compiler’s complexity
with no toolchain changes.
Honest about its shape: sqlc introduces zero enums. Its discriminators are
wire-coupled — integer ordinals mirroring libpg_query’s protobuf enums, the
ast.Node interface hierarchy, and YAML/config strings — so the wire and
serialization formats are preserved byte-for-byte rather than reshaped.
Notes
Faithful to pinned upstream MIT provenance (© 2019 Kyle Conroy and the sqlc
authors). Third-party dependencies (ANTLR, wazero, pg_query, the TiDB parser)
are unchanged. See the repository’s PARITY.md for the phase-by-phase ledger.