Skip to content

Contributing

Requirements: Go 1.27+, Nix (optional, recommended)

Terminal window
git clone https://github.com/LarsArtmann/cmdguard.git
cd cmdguard
nix develop # or: ensure GOEXPERIMENT=jsonv2 is set
go mod download
Terminal window
go build ./...
Terminal window
# All tests with race detection
go test ./... -count=1 -timeout 120s -race
# Coverage report
go test ./... -count=1 -timeout 120s -cover
Terminal window
golangci-lint run ./...

The project maintains 0 lint issues via real code fixes, not silencing linters.

Each sub-module (glamour, prompts, spinner, telemetry, flightrecorder, lint, schema) has its own go.mod. Build and test them individually:

Terminal window
for m in glamour prompts spinner telemetry flightrecorder lint schema; do
(cd $m && go build ./... && go test ./...)
done
  • gofumpt formatting (via golangci-lint fmt)
  • t.Parallel() in every test function and subtest
  • //nolint:paralleltest for tests using t.Setenv
  • Table-driven tests: tests := []struct{...} pattern
  • Single internal test package (v5, accesses private helpers)
  • Error wrapping: fmt.Errorf("context: %w", err)
  • Functional options pattern for all configuration
  • No panics in library code — all functions return errors

All pull requests must pass:

  • go build ./... — compiles cleanly
  • go test -race ./... — tests pass with race detection
  • golangci-lint run — no lint issues

The site is English-only by decision: no hreflang alternates are emitted and none are planned until a second language actually ships. Do not add locale scaffolding (i18n routing, language pickers, hreflang link tags) without a real second-language content source.

  • Ensure all tests pass: go test -race ./...
  • Ensure linting passes: golangci-lint run ./...
  • Add tests for new functionality
  • Keep changes focused and atomic
  • Follow existing patterns (check similar code)

The pre-commit hook runs golangci-lint + formatters automatically. Auto-fixes are applied, so commits proceed normally without --no-verify.