Skip to content

feat: add golangci-lint config and apply Go best practices#29

Merged
aaearon merged 1 commit intomainfrom
feat/go-best-practices
Feb 21, 2026
Merged

feat: add golangci-lint config and apply Go best practices#29
aaearon merged 1 commit intomainfrom
feat/go-best-practices

Conversation

@aaearon
Copy link
Owner

@aaearon aaearon commented Feb 21, 2026

Summary

  • Add .golangci.yml with 19 linters enabled (defaults + bodyclose, errorlint, noctx, gosec, errname, gocritic, misspell, revive, gocognit, perfsprint, unconvert, usetesting) with tuned exclusions for test files and Cobra conventions
  • Add package doc comments to all 6 packages per godoc conventions
  • Fix all lint issues surfaced by the new config (~50 fmt.Errorf -> errors.New, ~40 context.Background() -> t.Context(), octal literals, misspellings, param combining, else-if simplification)
  • Refactor resolveAndElevateUnified (complexity 57 -> under 40) and runFavoritesAddWithDeps (complexity 56 -> under 40) by extracting helper functions
  • Add -trimpath flag and CommitDate/mod_timestamp to Makefile and .goreleaser.yaml for reproducible builds
  • Update CLAUDE.md with lint config documentation and build notes

Test plan

  • make test passes (all existing tests)
  • make lint passes with zero issues
  • go vet ./... passes
  • make build produces a working binary with -trimpath
  • Refactored functions preserve all existing test coverage

- Add .golangci.yml with 19 linters (defaults + bodyclose, errorlint,
  noctx, gosec, errname, gocritic, misspell, revive, gocognit,
  perfsprint, unconvert, usetesting)
- Add package doc comments to all packages
- Replace fmt.Errorf with errors.New for static error strings
- Replace context.Background() with t.Context() in tests
- Use Go 1.13+ octal literal syntax (0o644 instead of 0644)
- Fix misspelling: cancelled -> canceled
- Combine same-type function parameters
- Refactor resolveAndElevateUnified and runFavoritesAddWithDeps to
  reduce cognitive complexity below gocognit threshold of 40
- Add -trimpath to Makefile and .goreleaser.yaml for reproducible builds
- Use CommitDate and mod_timestamp in .goreleaser.yaml
@aaearon aaearon merged commit ecd566c into main Feb 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant