ORM Adapters
go-audit ships first-class adapters for the three most popular Go ORMs. Pick the one matching your stack — installation is identical across all three.
Currently viewing the GORM adapter. Switch tabs above to see Bun and Ent installation flows.
Install the GORM adapter
Pull the adapter package alongside the core go-audit module. The adapter only depends on what you already have in your GORM project.
$ go get github.com/gopackx/go-audit/adapters/auditgormRegister the plugin
Once installed, plug the adapter into your GORM database. It hooks into create, update, and delete callbacks automatically.
import "github.com/gopackx/go-audit/adapters/auditgorm"
// after auditor is initialised
_ = gormDB.Use(auditgorm.Plugin(auditor, auditgorm.Options{
SkipUnchanged: true,
IgnoreTables: []string{"sessions"},
}))What gets captured
The plugin records mutations driven through GORM. Raw SQL queries that bypass GORM's callbacks are not captured — use the API logging middleware for those.
INSERTUPDATEDELETEBulk insertSoft deleteRaw SQLSoft delete detection
GORM marks rows as soft-deleted when the model embeds gorm.DeletedAt. The adapter detects this convention automatically — you don't need to configure anything.
type User struct {
ID uint
Email string
DeletedAt gorm.DeletedAt `gorm:"index"`
}Comparison: GORM vs Bun vs Ent
All three adapters expose the same auditing surface. Differences come down to how each ORM exposes hooks and metadata.