Contributing
Development Setup
Section titled “Development Setup”Requirements: Go 1.26.7 (exact — see go.mod), Nix (optional but recommended)
git clone https://github.com/LarsArtmann/samber-do-auditlog.gitcd samber-do-auditloggo mod downloadNix DevShell
Section titled “Nix DevShell”For the full toolchain (Go, templ, golangci-lint, govulncheck, actionlint):
nix developBuilding
Section titled “Building”go build ./...go generate ./... # regenerate templTesting
Section titled “Testing”# Run all testsgo test ./...
# With race detector (CI uses this)go test -race ./...
# Coverage gate (CI: >= 94% of non-example/cmd code)sh scripts/coverage-gate.shLinting
Section titled “Linting”Uses golangci-lint v2 with nearly every linter enabled:
golangci-lint config verify # validate configgolangci-lint run # full lintgo vet ./... # static analysisRunning the Example
Section titled “Running the Example”DO_AUDITLOG_ENABLED=true go run ./exampleThe example demonstrates every major samber/do v2 feature with a ride-sharing domain model.
Code Style
Section titled “Code Style”- Table-driven tests with
t.Parallel()for test isolation - Functional options pattern for configuration
- Strong types over runtime checks
- Early returns over nested conditionals
exhaustruct: all struct fields must be explicitly initialized (tests exempted)- JSON tags use snake_case via
tagliatelle
Pre-Commit Hook
Section titled “Pre-Commit Hook”git config core.hooksPath scripts/hooksThe hook runs: generate drift check, go vet, golangci-lint, go test -race.
All pull requests must pass 7 parallel jobs:
- test:
go vet,go build,go test -racewith coverage gate (>= 94%) - lint:
golangci-lint config verifythengolangci-lint v2.12.2 - vulncheck:
govulncheckpinned viago run golang.org/x/vuln/cmd/govulncheck@v1.7.0 ./... - mod-tidy:
go mod tidydrift check (transport-flake tolerant) - stale-generation: committed-generated-files guard +
go generate ./...diff check - actionlint: workflow lint
- example-smoke: runs the 23-feature self-checking example
A weekly scheduled run (Mondays 05:00 UTC) sweeps for new advisories and rot between pushes.
Pull Requests
Section titled “Pull Requests”- Ensure all tests pass:
go test -race ./... - Ensure linting passes:
golangci-lint run - Add tests for new functionality
- Keep changes focused and atomic
- Update
CHANGELOG.mdunder[Unreleased]