go-auditGo Audit
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-audit

The 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.

ORMPackage
GORMgo get github.com/gopackx/go-audit/adapters/gorm
Bungo get github.com/gopackx/go-audit/adapters/bun
Entgo get github.com/gopackx/go-audit/adapters/ent

Supported Databases

DatabaseJSON TypeIndex Strategy
PostgreSQLJSONBB-tree + GIN indexes on JSON
MySQLJSONInline B-tree indexes
SQLiteTEXTB-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.

On this page