🔔 FOLLOW GOLAB CHANNEL 🔔
ABSTRACT:
Using sqlc (a SQL compiler) in Go is great for generating type-safe database access. However, using the structs generated by sqlc directly in the business logic layer would tightly couple the domain to the database schema. To keep things flexible, a repository layer is needed to map between generated structs and domain models. But writing this mapping by hand quickly becomes repetitive.
The talk begins with a review of the evolution of working with Postgres in Go: from the standard library’s database/sql, through Squirrel + sqlx, pgx driver and API, to modern SQL-first approaches with sqlc. It then introduces an AI-powered generator that creates repository layers based on provided interfaces and domain models, leveraging sqlc-generated queries. The generator, playfully named sqlc++, is powered by Claude Code with a custom command and uses a GitHub project with a reference implementation as an example. This reference-based approach reduces LLM hallucinations and ensures consistent code style.
This approach makes it easier to bootstrap a new repository: in addition to what sqlc already requires (SQL schema and queries), one has to define domain models and a repository interface. From there, the sqlc++ generator produces the repository implementation and integration tests, ensuring consistency and avoiding repetitive boilerplate.
This channel is dedicated to the videos of the GoLab conference.
💛 Follow us on X:
/ golab_conf
💜 Follow us on FACEBOOK:
/ golabconf
GoLab is the first Italian international conference on the Go programming language, organized by Develer.
Develer is not just an Italian company projecting and releasing hardware and software solutions for the industrial environment, but is also an ensemble of people sharing their great passion for new technologies and how they can be applied to your everyday life.
🔸 Follow DEVELER on INSTAGRAM:
/ wearedeveler
🔹 Follow DEVELER on FACEBOOK:
/ we.are.develer
🔸 Follow DEVELER on X:
/ develer
🔹 Follow DEVELER on LINKEDIN:
/ 114426
🔸 Follow DEVELER on TELEGRAM: https://t.me/wearedeveler
🔹 Follow DEVELER on TIK TOK:
/ wearedeveler