This PR adds basic linting to CI for the repository.
First, a preview:
% make help
help: Prints list of targets and help for them.
build: Builds all packages.
test: Tests all packages.
lint: Runs various analyses on the code.
gofmt: Makes all files gofmt compliant.
check-gofmt: Checks that all files are gofmt-compliant.
tidy: Makes go.mod and go.sum up-to-date
check-tidy: Checks that go.mod/go.sum are up-to-date.
mdfmt: Reformats Markdown files with markdownfmt.
check-mdfmt: Verifies that all Markdown files are properly formatted.
What's included
Currently, linting (make lint) performs three checks:
code is formatted with gofmt (make check-gofmt)
markdown files are formatted with markdownfmt (make check-mdfmt)
go.mod and go.sum are up-to-date (make check-tidy)
Because the behavior of gofmt changes between versions of Go,
linting runs in CI only on the latest version of Go.
The make check-* targets above include non-check variants to fix the
problems they find.
For example, make gofmt reformats Go code,
and make check-gofmt verifies that it's formatted properly.
Why the other changes?
This includes two changes besides the GitHub Workflow and the Makefile:
markdownfmt_test.go wasn't properly gofmt-ed
README.md was not formatted with markdownfmt
As part of adding these checks to linting, this PR also fixes these issues.
So the README.md is now markdownfmt-compliant.
Why no other linters?
The change is already pretty large,
so I elected to skip third-party linters for now.
A future change could add staticcheck, golangci-lint, etc. if desired.
This PR adds basic linting to CI for the repository.
First, a preview:
What's included
Currently, linting (
make lint
) performs three checks:make check-gofmt
)make check-mdfmt
)make check-tidy
)Because the behavior of gofmt changes between versions of Go, linting runs in CI only on the latest version of Go.
The
make check-*
targets above include non-check variants to fix the problems they find. For example,make gofmt
reformats Go code, andmake check-gofmt
verifies that it's formatted properly.Why the other changes?
This includes two changes besides the GitHub Workflow and the Makefile:
As part of adding these checks to linting, this PR also fixes these issues. So the README.md is now markdownfmt-compliant.
Why no other linters?
The change is already pretty large, so I elected to skip third-party linters for now. A future change could add staticcheck, golangci-lint, etc. if desired.
Refs #30
Each commit is independently reviewable.