API Reference
API Reference
Public API for the Auditor type. Every method takes a context.Context and wraps errors with fmt.Errorf for cause inspection.
Complete reference for Go Audit's public API. Every method on the
Auditor accepts a context.Context and returns errors wrapped with
fmt.Errorf for cause inspection.
Sections
- Core —
audit.New,NewWithStore,Config, and theAuditorinterface. - Data Audit API —
RecordDataChange,Query, and theDataEntry/AuditLogtypes. - API Audit API —
API().Record,API().Query, and theAPIEntry/AuditAPILogtypes. - Query & Filters —
QueryByTransaction, pagination,Purge,Snapshot, andRestore. - Dialect Interface — built-in dialects and registering a custom one.
- Store Interface — the persistence abstraction and how to plug in your own.
The Auditor Interface
type Auditor interface {
RecordDataChange(ctx context.Context, entry DataEntry) error
API() APIAuditor
Query(ctx context.Context, filter DataFilter) ([]AuditLog, error)
QueryByTransaction(ctx context.Context, txID string) (*TransactionLog, error)
AutoMigrate(ctx context.Context) error
Purge(ctx context.Context, before time.Time) (PurgeResult, error)
Snapshot(ctx context.Context, entityType, entityID string, at time.Time) (map[string]any, error)
Restore(ctx context.Context, entityType, entityID string, at time.Time) (*RestoreResult, error)
Config() Config
}