CI: Add golangci-lint, enforce Go best practices #335
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch adds golangci-lint to the CI build/makefile. (Linters linting linters! 😵)
The configuration I've added (see
.golangci-lint.yml
) enables the following lints:I disabled a handful of others. Mostly because they are too opinionated (
gocritic
,whitespace
,wsl
, etc), not applicable (depguard
,godox
,gosec
), or produced too many findings to address in this PR (golint
,stylecheck
,goconst
). One day I'd like to come back around to enabling that last category when I can find the time to implement all of the renames/fixes required.I broke up each commit in this branch based on the lint error that was being fixed. Mostly these are small diffs and a few caught real bugs (e.g. unit tests that were never run, dead code, missed err checking).
The home-spun
make format-check
target can be replaced entirely since it's now subsumed by thegofmt
linter run bygolangci-lint
.