Member-only story
I Stopped Writing db: Tags in Go — Here’s What I Use Instead
sqlc generates type-safe Go code from your SQL queries — no struct tags, no manual scanning, no runtime mismatches.
If you’ve spent any time with sqlx or raw database/sql in Go, you know the ritual. You write a SQL query, then you write a struct, then you tag every field with db:”column_name”, then you pray the column order matches. It works. But it’s also the kind of work that feels like it shouldn’t exist in 2024.
There’s a tool called sqlc that flips this entire workflow upside down. Instead of writing Go structs and hoping they match your database schema, you write SQL first — and sqlc generates the Go code for you. Type-safe, zero reflection, zero manual struct tags.
I’ve been using it in production for over a year. Here’s an honest look at what it gets right, where it still has rough edges, and whether it’s worth switching from sqlx.
The Core Problem sqlc Solves
Let me show you the exact friction sqlc eliminates. Here’s a typical sqlx workflow for listing orders with their customer name and total amount:
// You write this struct manually
type Order struct {
ID int `db:"id"`
CustomerID int…




