A CLI and Go library for managing database schema changes through versioned SQL files or Go functions.
go-gorm/gorm
A full-featured ORM for Go that maps structs to database tables and supports associations, hooks, transactions and migrations.
- Stars
- 39,978
- Forks
- 4,220
- Open issues
- 554
- Last commit
- last month
What is it?
GORM is an object-relational mapping library for Go. It lets developers define models as Go structs and perform create, read, update and delete operations without writing raw SQL for every query, while still offering a SQL builder and raw SQL when needed.
The library covers common relational patterns: has one, has many, belongs to, many to many, polymorphic associations and single-table inheritance, with eager loading through Preload and Joins. It also provides transactions with save points, batch inserts, upserts, row locking, hooks around create, update, delete and find operations, and automatic schema migrations.
GORM is extensible through a plugin API. Its documented plugins include a database resolver for multiple databases and read/write splitting, and a Prometheus integration. Documentation and guides are hosted at gorm.io.
Key features
- 01Associations including has one, has many, belongs to, many to many and polymorphic.
- 02Eager loading via Preload and Joins.
- 03Transactions with nested transactions and save points.
- 04Batch insert, upsert, row locking and FindInBatches.
- 05Hooks for create, save, update, delete and find.
- 06Auto migrations and a plugin API.
Use cases
- Building a Go web service backed by a relational database without hand-writing SQL for every query.
- Adding read/write splitting or multiple database connections through the resolver plugin.
- Managing schema changes during development with automatic migrations.
Quick start
- 1
Read the GORM guides at gorm.io for installation and usage
Topics
FAQ
- What is gorm?
- A full-featured ORM for Go that maps structs to database tables and supports associations, hooks, transactions and migrations. GORM is an object-relational mapping library for Go. It lets developers define models as Go structs and perform create, read, update and delete operations without writing raw SQL for every query, while still offering a SQL builder and raw SQL when needed.
- Is gorm free to use? What license does it have?
- gorm is open source under the MIT license. Check the license terms before using it in commercial products.
- Is gorm still maintained?
- Updated within 6 months. The last commit to gorm was on Sep 14, 2026.
- What can I use gorm for?
- Building a Go web service backed by a relational database without hand-writing SQL for every query. Adding read/write splitting or multiple database connections through the resolver plugin. Managing schema changes during development with automatic migrations.
- How do I install gorm?
- Read the GORM guides at gorm.io for installation and usage
- Where can I get gorm?
- The source code and installation instructions are on GitHub: https://github.com/go-gorm/gorm
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
TypeScript ORM for Node.js that gives type-safe database access across PostgreSQL, MySQL, SQLite, MongoDB and other databases.
Free multi-platform desktop SQL client and database tool supporting 100+ databases via JDBC and ODBC drivers.
A TypeScript and JavaScript ORM for Node.js and other JS platforms, supporting both Active Record and Data Mapper patterns across many SQL and NoSQL databases.
A promise-based Node.js and TypeScript ORM for PostgreSQL, MySQL, MariaDB, SQLite, MS SQL Server, Snowflake, Oracle and Db2.
The Go programming language, an open source language for building simple, reliable, and efficient software.