Skip to content
CAI
Software that uses CAICheck a score

go-gorm/gorm

66.2

Adequate · 24 September 2026

13.3k

lines of production code

Go

primary language

5

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

This system is a Go Object-Relational Mapping (ORM) library that facilitates type-safe database interactions through a generics API and a modular SQL clause generation engine. It provides comprehensive schema management via a database-agnostic migrator interface and supports complex data relationships through an association mode with extensible callback hooks. The library ensures robust performance and maintainability by integrating thread-safe caching, standardized logging, and extensive test coverage across multiple database dialects.

Features

GORM v2 release with generics API and association mode

This release introduces GORM v2, featuring a new Generics API for type-safe database operations, a redesigned Association Mode for easier relationship handling, and a callback-based architecture for extensibility. The update includes comprehensive support for soft deletes, joins, and batch operations, alongside new error types for constraint violations and a Code of Conduct for the project.

(repo-wide) · high confidence

Initial implementation of the SQL clause generation engine

The \clause\ package introduces the foundational building blocks for constructing SQL statements, including specific clause types for SELECT, FROM, WHERE, JOIN, GROUP BY, HAVING, ORDER BY, LIMIT, OFFSET, INSERT, UPDATE, DELETE, ON CONFLICT, and RETURNING. It provides expression interfaces for handling conditions, named parameters, and raw SQL, along with support for association operations and locking strategies, enabling the ORM to compose complex queries from modular components.

clause · high confidence

Introduce abstract Migrator interface and implementations

The migrator package now provides a unified, database-agnostic interface for schema management, decoupling migration logic from specific dialects. This change introduces concrete implementations for core migration operations—including table creation, column migration, index handling, and constraint management—along with dedicated types for column, index, and table metadata. Users benefit from a consistent API for AutoMigrate and manual schema adjustments that works across all supported databases, while the underlying dialect-specific logic is now cleanly separated within the migrator layer.

migrator · high confidence

Introduction of the callbacks package with default lifecycle hooks

The \callbacks\ package has been added to provide the default callback functions for GORM operations such as create, query, update, and delete. This includes the registration of standard hooks like \BeforeCreate\, \AfterCreate\, \BeforeUpdate\, \AfterUpdate\, \BeforeDelete\, and \AfterDelete\, as well as association handling via \SaveBeforeAssociations\ and \SaveAfterAssociations\. The package also introduces interfaces for these hooks (\BeforeCreateInterface\, etc.) and helper functions for converting map values and handling transactions, establishing the core execution flow for database interactions.

callbacks · high confidence

Behavioural changes

Improved stack trace accuracy and new utility functions

The \utils\ package now provides more accurate source file and line number reporting in logs and errors by refining the \CallerFrame\ logic to correctly skip GORM internal files, test files, and generated \.gen.go\ files, while also introducing a \FileWithLineNum\ function for consistent formatting. Additionally, new utility functions have been added to support internal operations: \IsInvalidDBNameChar\ for validating database names, \CheckTruth\ for boolean string evaluation, \ToStringKey\ for generating hashable keys from mixed types, \AssertEqual\ for deep equality checks respecting \driver.Valuer\, \ToString\ for numeric type conversion, and \RTrimSlice\ for generic slice trimming.

utils · high confidence

Internal LRU cache and SQL statement store refactored for thread safety and expiration

The internal LRU cache implementation now uses sync.RWMutex to allow concurrent read access for methods like Contains and Peek, improving performance for read-heavy workloads. The SQL statement store has been updated to use this new LRU cache, which supports configurable time-to-live (TTL) expiration and eviction callbacks, ensuring that prepared statements are automatically cleaned up after a specified duration or when the cache size limit is reached.

internal · high confidence

Logger refactored with new slog integration and SQL formatting improvements

The logger package has been restructured to support the Go 1.21+ standard library \log/slog\ via a new \slogLogger\ implementation, while retaining the original \logger\ for older Go versions. The SQL explanation logic in \sql.go\ has been rewritten to handle \driver.Valuer\ and \fmt.Stringer\ interfaces more robustly, ensuring correct parameter formatting and preserving float precision. Additionally, the \slogLogger\ now correctly detects the caller source file for log entries, and the \Config\ struct explicitly supports \ParameterizedQueries\ and \IgnoreRecordNotFoundError\ options.

logger · high confidence

Schema package refactored with new constraint, index, and naming strategy implementations

The schema package has been restructured to introduce dedicated modules for database constraints, indexes, and naming strategies. Users can now define check and unique constraints via struct tags, which are parsed into specific \CheckConstraint\ and \UniqueConstraint\ types. Index definitions have been expanded to support composite indexes, priority ordering, and various database-specific options like type, where clauses, and collation. Additionally, the \NamingStrategy\ has been enhanced with a \Replacer\ interface for custom name transformations and a configurable \IdentifierMaxLength\ to handle long identifiers safely. These changes provide more granular control over database schema generation and migration behavior.

schema · high confidence

Test coverage

Add test infrastructure for GORM dialects and model relationships; Comprehensive test suite for GORM associations and generics API.

Dependencies

Initial Go module setup with GORM v1.31.0 and updated database drivers

The project initializes its Go module structure, establishing the main \gorm.io/gorm\ module (Go 1.18) and a separate \gorm.io/gorm/tests\ module (Go 1.24.0). The test suite is configured to use GORM v1.31.0 and updates several database drivers, including MySQL, PostgreSQL, SQL Server, and SQLite (all at v1.6.0), while adding support for the GaussDB driver (v0.1.0).

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 57 → 66 (+9.1)
  • Rubric changed (rubric-2026.08.19 → rubric-2026.09.15) — scores are not directly comparable.

Lenses

  • Code Health 53 → 68 (+15.5)
  • Architecture 100 → 99 (-0.8)
  • Maturity 57 → 57 (+0.2)
  • Readiness 76 → 81 (+4.9)
  • Security 53 → 75 (+22.4)

Resolved (43)

  • Coverage not included — suite not readable by the collector
  • Dependency hygiene not measured — dependency manifest found but not parsed for hygiene
  • Duplicated block (10 lines × 2) (association.go)
  • Duplicated block (10 lines × 2) (callbacks/associations.go)
  • Duplicated block (10 lines × 2) (callbacks/associations.go)
  • Duplicated block (10 lines × 2) (callbacks/associations.go)
  • Duplicated block (12 lines × 2) (clause/where.go)
  • Duplicated block (5 lines × 2) (callbacks/associations.go)
  • Duplicated block (5 lines × 2) (callbacks/delete.go)
  • Duplicated block (5 lines × 2) (schema/field.go)
  • Duplicated block (5 lines × 2) (schema/field.go)
  • Duplicated block (6 lines × 2) (finisher_api.go)
  • Duplicated block (6 lines × 2) (internal/lru/lru.go)
  • Duplicated block (6 lines × 2) (statement.go)
  • Duplicated block (7 lines × 2) (association.go)
  • Duplicated block (7 lines × 2) (association.go)
  • Duplicated block (7 lines × 2) (callbacks/associations.go)
  • Duplicated block (7 lines × 2) (callbacks/associations.go)
  • Duplicated block (7 lines × 2) (callbacks/preload.go)
  • Duplicated block (7 lines × 2) (chainable_api.go)
  • …and 23 more

New (97)

  • ClassTooLong: Field (schema/field.go)
  • ClassTooLong: Migrator (migrator/migrator.go)
  • ClassTooLong: Statement (statement.go)
  • Documentation: no installation or build instructions (README.md)
  • Documentation: no usage examples (README.md)
  • Duplicated block (10 lines × 2) (callbacks/associations.go)
  • Duplicated block (10 lines × 2) (finisher_api.go)
  • Duplicated block (10 lines × 2) (migrator/migrator.go)
  • Duplicated block (10–11 lines × 3) (callbacks/associations.go)
  • Duplicated block (11 lines × 2) (schema/schema.go)
  • Duplicated block (12 lines × 2) (association.go)
  • Duplicated block (13–15 lines × 2) (callbacks/associations.go)
  • Duplicated block (14 lines × 2) (clause/where.go)
  • Duplicated block (28 lines × 2) (generics.go)
  • Duplicated block (5 lines × 2) (callbacks/delete.go)
  • Duplicated block (5 lines × 2) (generics.go)
  • Duplicated block (5 lines × 2) (internal/lru/lru.go)
  • Duplicated block (5 lines × 2) (schema/field.go)
  • Duplicated block (5 lines × 2) (schema/field.go)
  • Duplicated block (5 lines × 3) (callbacks/associations.go)
  • …and 77 more

Changes since last survey

  • 1 commits — 1 feature/other, 0 fixes

By area

  • .github/workflows — 1 commit

Notable commits

  • change: ci: bump golangci-lint to v2.13 for current Go stable compatibility (#7861)

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

go-gorm/gorm was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 24 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit b3d3bf219f0283f8e2e985bac509cb643170f729 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-5f8d0eb43fd7.