GORM — Overview#
Identity#
- Module path: gorm.io/gorm
- Go version: 1.18
- License: MIT
- Repository: https://github.com/go-gorm/gorm
Purpose#
GORM is a full-featured ORM (Object-Relational Mapper) library for Go, designed to be developer-friendly. It abstracts database interactions by mapping Go structs to database tables, handling queries, associations, migrations, and transactions — allowing developers to work with SQL databases using idiomatic Go code rather than raw SQL. It targets Go developers who want ergonomic database access without sacrificing control.
Significance#
GORM is the dominant ORM in the Go ecosystem, widely regarded as the de facto standard for ORM-style database access in Go. It has been actively maintained since 2013 (v1) with a major v2 rewrite (the current module at gorm.io/gorm) that addressed architectural shortcomings of v1. With tens of thousands of GitHub stars and broad adoption across production systems, it has influenced how the Go community thinks about database abstraction, dialect-based extensibility, and plugin systems. Many competing libraries benchmark themselves against or explicitly position against GORM.
Key metrics#
- Go files: 162
- Top-level directories:
callbacks/,clause/,internal/(lru, stmt_store),logger/,migrator/,schema/,tests/,utils/ - Direct dependencies: 3 (
jinzhu/inflection,jinzhu/now,golang.org/x/text) - First commit / age: Originally created ~2013; current v2 module cloned 2026-03-23 (shallow clone)
Notable characteristics#
- Extremely lean dependency footprint: Only 3 direct dependencies (inflection, time parsing, text normalization). All database drivers are provided by separate dialect packages (
gorm.io/driver/...), keeping the core library pure and portable. - Dialector interface for multi-database support: The
Dialectorinterface abstracts all database-specific behavior (quoting, type mapping, binding, migration). This clean separation means the core compiles without any database driver, and dialects ship independently. - Plugin system via
Plugininterface: Plugins integrate by implementingName() stringandInitialize(*DB) error, giving them full access to*DBduring setup. This powers extensions like prometheus metrics, database resolvers (read/write splitting), and sharding. - Clause-based SQL builder: The
clause/package implements a composable SQL AST. Rather than string concatenation, GORM builds queries by assembling typed clause expressions (SELECT, WHERE, ORDER BY, etc.), enabling safe and composable query construction. - Requires Go 1.18 and leverages generics: The
generics.gofile provides genericFind,First, etc. wrappers, offering type-safe query results without reflection-based boilerplate in user code — a significant ergonomic improvement adopted with Go’s generics introduction.