finds.dev← search

// the find

doug-martin/goqu

★ 2,667 · Go · MIT · updated May 2024

SQL builder and query library for golang

goqu is a SQL query builder for Go that sits between raw string concatenation and a full ORM. It generates SQL for Postgres, MySQL, SQLite, and SQL Server with a fluent API, handles parameter interpolation, and can scan results into structs. It's aimed at teams who want type-safer query construction without the magic of GORM.

The dialect abstraction is genuinely useful — swapping Postgres for SQLite in tests is a one-line change. The `goqu.Ex` map syntax for WHERE clauses keeps simple filters readable without a pile of method chains. Test coverage is solid across all four dialects with real database integration tests, not just mocks. The separation between query building (`ToSQL()`) and execution means you can use it purely as a SQL generator if you already have your own db layer.

Last commit was May 2024 and the pace has been slow for years — open issues with no response are common. No support for upsert syntax across all dialects (Postgres has ON CONFLICT, but it's inconsistent). The `goqu.Ex` operator map (`goqu.Op{"gt": 10}`) is clever but brittle — typo a key and you get a runtime panic, not a compile error. Window functions and CTEs exist but feel bolted-on; anything complex enough to need them is probably better written as raw SQL.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →