Go ORM Libraries
Go ORM Libraries
Go ORM libraries emphasize simplicity and performance. GORM is the most popular with developer-friendly APIs, Ent offers graph-based data modeling, and SQLC provides compile-time type safety. Following Go's philosophy, they focus on generating explicit and understandable code.
GitHub Star Comparison
No | Name | GitHub Stars | Description | Trend | License | Type | Official Site |
---|---|---|---|---|---|---|---|
1 | GORM | ⭐ 38.5k | GORM is the most popular ORM library for Go, designed with developer experience as the top priority. It adopts a code-first approach and provides a simple, intuitive API. GORM supports multiple databases including MySQL, PostgreSQL, SQLite, and SQL Server, and comes with built-in association, hook, and auto-migration features. | stable | MIT | Library | Official |
2 | Beego ORM | ⭐ 32.2k | Beego ORM is "an ORM that enhances Go application productivity with Django-like APIs" developed as a core component of the popular Beego web framework in the Go ecosystem. With intuitive API design inspired by Django and SQLAlchemy, it simplifies database operations through a Code First approach. Supporting MySQL, PostgreSQL, and SQLite3, it efficiently handles complex query operations and relationship management while maintaining type safety. | stable | Apache-2.0 | Library | Official |
3 | sqlx | ⭐ 17.1k | sqlx is a powerful extension library for Go's standard database/sql package. It positions itself between raw SQL and full ORMs, providing additional convenience features while maintaining the performance and flexibility of database/sql. sqlx adds missing features like named parameters, struct scanning, and result mapping without sacrificing control over SQL queries. | stable | MIT | Library | Official |
4 | Ent | ⭐ 16.4k | Ent is a Go entity framework that adopts a "Schema as Code" approach. Inspired by an entity framework used internally at Meta (Facebook), it provides complete type safety and explicit APIs through code generation. Supporting multiple databases including MySQL, PostgreSQL, SQLite, and CockroachDB, it offers comprehensive enterprise-level features such as GraphQL integration, advanced migration with Atlas integration, and graph traversal queries as a modern Go ORM solution. | stable | Apache-2.0 | Library | Official |
5 | sqlc | ⭐ 15.7k | sqlc is "Generate type-safe Go from SQL" - a Go-specific SQL query compiler that automatically generates type-safe Go code from raw SQL files and performs compile-time SQL syntax checking and type validation. Without going through ORM abstraction layers, it maximizes SQL's expressiveness while providing Go's type safety and IDE support. It automatically detects changes in database schemas and SQL queries, regenerating corresponding Go code to maintain consistency between SQL and Go code at all times, significantly reducing runtime errors. | stable | MIT | Library | Official |
6 | upper/db | ⭐ 3.6k | upper/db is developed as "A productive data access layer for Go" - a Data Access Layer (DAL) library for Go that supports PostgreSQL, CockroachDB, MySQL, SQLite, and MongoDB. While providing ORM-like features, it offers tools for handling common database operations while remaining unobtrusive in advanced scenarios. It enables collaboration with different data sources through a unified API regardless of SQL or NoSQL databases, with a design that emphasizes the balance between productivity and flexibility. | stable | MIT | Library | Official |