Contributing
Development Setup
Section titled “Development Setup”Requirements: Go 1.26+, 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: >= 95% of non-example/ 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 19 samber/do v2 features 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 5 parallel jobs:
- test:
go vet,go build,go test -racewith coverage gate (>= 95%) - lint:
golangci-lint config verifythengolangci-lint v2.12.2 - vulncheck:
govulncheckvia GitHub Action - mod-tidy:
go mod tidydrift check - stale-generation:
go generate ./...diff check
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]