Getting Started
Installation
Install Go Audit core and your ORM adapter.
Requirements
- Go 1.22 or later
- One of: GORM, Bun, or Ent (the core itself only needs
database/sql) - A supported database: PostgreSQL, MySQL, or SQLite
Install Core
go get github.com/gopackx/go-auditThe core package depends only on the Go standard library — no external drivers, no HTTP clients.
Install ORM Adapter
Pick the adapter that matches your ORM. Each is a separate module so you only pull in the ORM you actually use.
| ORM | Package |
|---|---|
| GORM | go get github.com/gopackx/go-audit/adapters/gorm |
| Bun | go get github.com/gopackx/go-audit/adapters/bun |
| Ent | go get github.com/gopackx/go-audit/adapters/ent |
Supported Databases
| Database | JSON Type | Index Strategy |
|---|---|---|
| PostgreSQL | JSONB | B-tree + GIN indexes on JSON |
| MySQL | JSON | Inline B-tree indexes |
| SQLite | TEXT | B-tree indexes |
Set the Dialect
The dialect is not auto-detected — you always set it explicitly on the config:
audit.Config{
Dialect: audit.PostgreSQL, // or audit.MySQL, audit.SQLite
}Valid values are the constants audit.PostgreSQL, audit.MySQL, and
audit.SQLite. Custom dialects can be registered via
audit.RegisterDialect — see the Dialect reference.
Next Step
Continue to the Quick Start for a complete runnable example.