SQLC deep dive: how SQL become type-safe Go code

SQL-compiler or sqlc generates type-safe Go code from SQL migrations and queries. Most developers use it as a black box, but understanding how it works matters because great engineers don’t just use tools — they understand them, question them, and get better by knowing what’s happening under the hood.

We are going trace the compilation pipeline inside sqlc: how it delegates parsing to PostgreSQL’s own parser via pg_query_go, builds an in-memory schema catalog, performs query analysis and type inference across joins, CTEs, and subqueries, and finally generates Go code for PostgreSQL and pgx driver.

LEVEL: Intermediate

Place
Golab #2
Length
45 min
When
November 3rd, 2026
12:15

Abstract

SQL-compiler or sqlc generates type-safe Go code from SQL migrations and queries. Most developers use it as a black box, but understanding how it works matters because great engineers don’t just use tools — they understand them, question them, and get better by knowing what’s happening under the hood.

We are going trace the compilation pipeline inside sqlc: how it delegates parsing to PostgreSQL’s own parser via pg_query_go, builds an in-memory schema catalog, performs query analysis and type inference across joins, CTEs, and subqueries, and finally generates Go code for PostgreSQL and pgx driver.

Instead of magic, we are going see a real sqlc generator architecture: ASTs, catalogs, scope resolution, nullability inference, and type mapping.

GoLab is a conference made by Develer.
Develer is a company based in Campi Bisenzio, near Florence. Our motto is : "Technology to give life to your products". We produce hardware and software to create exceptional products and to improve industrial processes and people's well being.
In Develer we have passion for the new technologies and we offer our clients effective solutions that are also efficient, simple and safe for the end users. We also believe in a friendly and welcoming environment where anybody can give their contribution. This passion and this vision are what we've been driven to organize our conference "made by developers for developers".


Subscribe to our newsletter

We hate spam just as much as you do, which is why we promise to only send you relevant communications. We respect your privacy and will never share your information with third parties.
©2026 GoLab | The international conference on Go in Italy-Design & devCantiere Creativo-Made withDatoCMS