Something like sqlc[0] is leagues better than any ORM in terms of simplicity, complexity and maintainability.
The primary benefit of pggen and sqlc is that you don't need a different query model; it's just SQL and the tools automate the mapping between database rows and Go structs.
After sqlx, I gave sqlc (https://github.com/kyleconroy/sqlc) a try and I found it to be much more painless than any other database solution (for PostgreSQL) for Golang.
Edit: sqlc is an inversed solution. Instead of generating SQL queries using Golang, you write annotated SQL queries and sqlc generates Golang source from them.
https://github.com/kyleconroy/sqlc
SQLx is good for simple read queries, but iirc for write operations you still need to map things manually and reads with JOINs are a bit tricky. Gorm might be good for simple CRUD applications, but it's magic has a performance cost.
If you're looking for the ability to generate type-safe SQL – given you write SQL correctly – this project is pretty good.
Aalso a fan of SQLBoiler (https://github.com/volatiletech/sqlboiler) for Golang, for simple type safety:
`models.Accounts(models.AccountWhere.ID.EQ(id)).One(ctx, db)`.
Though SQLBoiler breaks with left joins, as it auto-generates your structs and maps results 1-1 with table definitions. In this case you have to custom type something, either using sqlc or squirrel.
sqlc currently has great support for Go and experimental support for Kotlin. I'm planning on adding TypeScript support in the future, so it's great to see that others in the TypeScript community find this workflow useful.
I'm writing a compiler for SQL that parses DDL (CREATE TABLE, etc.) and queries and outputs type-safe Go. It currently supports PostgreSQL, but the plan is to support more engines and more output programming languages.
Go and PostgreSQL are currently supported, with Kotlin and MySQL support on the way.
In addition to catching SQL errors, it generates type-safe Go wrapping code. Right now it supports PostgreSQL and MySQL.
I’m (obviously) a huge fan of the SQL first approach and hope more people adopt it for their own projects.
As for migrations, I've had success with https://github.com/pressly/goose. It's lightweight and is also just SQL.