Gnorm vs ...


GORM is a Go ORM.


  1. GORM is code-first. It generates the database from your code, using GORM-specific techniques that obscure what’s really happening in the DB.
    • Gnorm is database-first. You generate your database using the first class tools for your DB (sql, pgAdmin, whatever).
  2. GORM is only for go.
    • Gnorm can generate code for any language, or even docs or protobufs.
  3. GORM is a framework (it calls you) that uses a ton of reflection, special tags, and naming conventions to create behaviors. This makes it run slow, and makes reading and debugging the code difficult.
    • Gnorm generates simple, easy-to-understand boilerplate that would be tedious and error-prone to write, but offers the best speed and least complexity.


SqlBoiler is a database-first fluent-api generator for Go.


  1. Workflow and Templates:
    • SQLBoiler’s default workflow is to use the templates provided to get something working out of the box immediately, whereas writing your own templates is considered an advanced feature.
    • Gnorm’s primary focus is user-written templates with full control of the output text and files (for example, the filenames and directories generated by Gnorm can use templated DB info).
  2. Generated API style:
    • SQLBoiler’s default template set uses a fluent API which is typically viewed as non-idiomatic in Go.
    • Gnorm’s example templates generate idiomatic go code (or non-idiomatic code, if that’s what you want!).
  3. Type safety:
    • SQLBoiler uses type-unsafe interface{} and developer written strings for clauses where conditions are involved (where, inner join). Where(models.PersonColumns.Age + “ > ?”, 30) which can lead to typos and type-incompatibility. If you change the type of a column this code will not fail until it’s used in a test or production. Only a name change will cause this to fail (unless you completely replace the templates with something type safe).
    • Gnorm on the other hand can generate type-safe queries that ensure if a column’s type changes your code will fail to compile.
  4. Relationship support:
    • SQLBoiler supports complex joins and relationship queries which allows you to get the data you want efficiently out of your DB (one-to-one, one-to-many, many-to-many, eager loads all supported)
    • Gnorm’s default templates do not support these out of the box just yet


XO is a code generator focused on producing Go code for your database.


  1. XO is mainly aimed at producing Go code and thus has a lot of assumptions built in (like what types you want to use to represent specific DB types).
    • Gnorm doesn’t make any assumptions about what you’re outputting, so you’re never “swimming upstream”.
  2. XO only produces code in a single directory with specifically named files. If you have a big DB schema (or even if you don’t), this limits you to long ugly names in order to namespace things, and prevents many more advanced layouts.
    • Gnorm lets you control the directory and filename generated for each schema, table, and custom type.
  3. XO has a mode that will output code that mimics a specific query.
    • Gnorm doesn’t have this, but you can generally generate code to support almost any query, and then just write the query yourself.


Many of these tools support more databases that Gnorm at this time (gnorm only supports Postgres and MySQL). All of these tools are fine works of craftsmanship and if they fit your need, you should absolutely use them.