Bob · type-safe SQL in Go, without the magic
4 months ago
In Go, you usually pick between two extremes. Raw query strings are fast, but a typo only blows up at runtime. A magic ORM is safe, but opaque. Bob is a third option: Go packages that generate fully type-safe queries from your own database, checked by the compiler, with no magic.
Ask about this presentation
Chapters
Show transcriptHide transcript
In Go, you usually pick between two extremes. Raw query strings are fast, but a typo only blows up at runtime. A magic ORM is safe, but opaque. Bob is a third option: Go packages that generate fully type-safe queries from your own database, checked by the compiler, with no magic.
So what is Bob? A set of Go packages for your database, adopted one layer at a time. Start with a fluent query builder, dialect-correct for Postgres, MySQL, and SQLite, so you can't build an invalid query. An executor scans results straight into your Go structs. And a generator reads your schema and writes type-safe models, plus factories. The principle: convenience, not magic.
You don't have to start with code generation. Bob's query builder is fluent and dialect-correct, and you can use it right away. Every argument is a query mod: a From, a Where, and so on. On its own, though, the builder can't check your column names.
Now the first win. Point Bob at a database you already have. One command: set the connection string, then go run the Postgres generator. Bob inspects your live schema and writes a fully type-safe models package, plus factories for your tests. There's a matching generator for MySQL and for SQLite.
Here's the payoff, the same query as before. The generated version is type-safe: every table and column is a real Go symbol, checked by the compiler. Rename a column, regenerate, and every wrong query fails to compile, caught before you ship, not in production.
Generation also gives you factories, inspired by Ruby's FactoryBot. Ask for ten comments and Bob creates them, wiring up the posts and users they depend on. Realistic test data from the same schema, without writing fixtures by hand.
That's the arc. A fluent query builder, type-safe models generated from your own database, and factories for your tests, adopted one layer at a time, with no magic. It works with Postgres, MySQL, and SQLite. Start here: bob dot stephenafamo dot com.
Up next
2:03cargo-nextest · a next-generation test runner for Rust
@github
4 months ago
1:35mq · jq, but for Markdown
@github
4 months ago
1:24Mimesis · realistic, locale-aware fake data in one line
@github
4 months ago
1:38pikepdf · open, edit and repair PDFs in Python, losslessly
@github
4 months ago
1:22tfswitch · the right Terraform version, automatically
@github
4 months ago
1:21PyPDFForm · fill a PDF form in Python in a few lines
@github
4 months ago
1:35MCP-UI - interactive apps for MCP tools
@github
4 months ago
1:39workmux - parallel coding agents in isolated worktrees
@github
4 months ago
1:33Pumpkin - start a Rust Minecraft server
@github
4 months ago
1:39Bifrost - your first reliable AI gateway
@github
4 months ago
1:39Honcho - memory that reasons across sessions
@github
4 months ago
1:56agentgateway · one governed proxy for your agent traffic
@github
4 months ago






