Contributing
How to build, test, and contribute to Go Audit.
Contributions are welcome. Bug reports, feature ideas, and pull requests all help.
Development Setup
git clone https://github.com/gopackx/go-audit
cd go-audit
go mod downloadGo 1.22 or later is required (matches the go.mod directive).
Running Tests
The core tests run against SQLite in-memory (no setup required). Integration tests against PostgreSQL and MySQL use Docker:
docker compose up -d # starts pg + mysql
go test ./...Run only the core (SQLite-backed) tests:
go test ./... # uses in-memory store by default
go test ./integration/... # requires DockerProject Layout
.
├── audit.go, auditor.go, api_auditor.go core types and implementations
├── config.go, types.go Config, structs, validation
├── diff.go, redact.go diff engine, redaction helpers
├── transaction.go, aliases.go context helpers, re-exports
├── dialect/ PG / MySQL / SQLite dialects
├── store/ Store interface, SQL + in-memory
├── migrate/ schema creation
├── entry/ persistent types (AuditLog, …)
├── adapters/
│ ├── gorm/ GORM plugin
│ ├── bun/ Bun QueryHook
│ └── ent/ Ent mutation hook
└── _examples/ runnable end-to-end samplesAdding a New Adapter
- Create a new package under
adapters/<orm>. - Expose a registration entry point. Existing patterns:
- GORM —
Plugin(auditor) gorm.Plugin - Bun —
Register(db, auditor) - Ent —
Hook(auditor) ent.Hook
- GORM —
- Hook into the ORM's lifecycle to capture create, update, and delete events.
- Reuse the core
AuditorviaRecordDataChange— don't duplicate diff or exclusion logic. - Add a full test suite that mirrors
adapters/gorm's layout.
See adapters/gorm for the reference implementation.
Adding a New Dialect
- Implement
dialect.Dialectfor your target database. - Register via
audit.RegisterDialect(DialectType("name"), impl). - Add dialect tests parallel to the built-ins under
dialect/.
Code Style
gofmt+goimports.golangci-lint runpasses with the repo's config.- Conventional commits:
feat: ...,fix: ...,docs: ...,chore: ....
Pull Request Process
- Fork, branch from
main. - Commit with conventional messages.
- Push and open a PR. CI must be green.
- A maintainer will review — please address comments and squash as requested.
Reporting Issues
Use the GitHub issue tracker. Include:
- Go version and OS
- ORM + database + dialect
- A minimal reproduction if possible
- What you expected vs what happened