// the find
huandu/go-sqlbuilder
A flexible and powerful SQL string builder library plus a zero-config ORM.
go-sqlbuilder is a pure SQL string construction library for Go — no connection, no driver, just builds parameterized SQL strings and argument slices. It sits between raw string concatenation and a full ORM: you get type-safe argument binding and composable WHERE/JOIN/CTE builders without giving up control of the query shape. Battle-tested at scale according to the README, and the claim is plausible given the depth of the implementation.
The Cond/WhereClause abstraction is the real win here — you can build a WHERE clause once and share it across a SELECT and an UPDATE without copying code. The flavor system handles placeholder differences (? vs $1) transparently, so switching from MySQL to PostgreSQL in tests doesn't require rewriting queries. Clone() on builders lets you define a base query globally and fork it per-request safely, which is the right pattern for high-throughput services. The Struct ORM layer generates Scan address slices directly from struct field order, which means you avoid the N+1 boilerplate of manually aligning Scan arguments to columns.
The interpolation feature ships a security warning in its own README — that's a red flag to ship to a team where someone might reach for it in a pinch and forget. The Struct tag surface area has grown large enough that it's effectively a mini-DSL (fieldtag, fieldas, fieldopt with omitempty(tag1,tag3) syntax, noexpand, expand, the global NoExpand flag) — understanding all the interactions requires reading the godoc carefully rather than guessing. There's no query validation at build time; typos in column names or table aliases produce syntactically correct but semantically wrong SQL with no feedback. The ORM side doesn't handle relationships at all, so anything beyond flat structs needs manual join projection via the nested struct expansion — not a flaw per se, but worth knowing before you assume it replaces sqlx.