summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
inline | side by side (from parent 1:
522d7fd)
The skills identify the linters that enforce error, assertion, name, and
spacing rules. They keep manual review for logical groups, local error
paths, and the config exceptions because passing lint does not prove
those rules.
## Procedure
1. Format all files with `bin/format`.
## Procedure
1. Format all files with `bin/format`.
-2. Run the checks with `bin/check`.
+2. Run the checks with `bin/check`. Its golangci-lint config keeps the
+ standard linters and adds `errorlint`, `gocritic`, `testifylint`,
+ `revive`, `wrapcheck`, `nlreturn`, and `wsl_v5`. The settings in
+ `.golangci.yml` match the Go rules.
3. Run `git add` on new files, then run `nix build` and
`nix flake check`.
4. Fix every failure and run the steps again. Do not disable a linter or
3. Run `git add` on new files, then run `nix build` and
`nix flake check`.
4. Fix every failure and run the steps again. Do not disable a linter or
- Write type names with a capital letter, so that a variable can have
the name of its type. Write all other package-level names in lower
case.
- Write type names with a capital letter, so that a variable can have
the name of its type. Write all other package-level names in lower
case.
-- Write all the letters of an initialism in one case.
+- Write all the letters of an initialism in one case. `revive` checks
+ common initialisms.
- Put entry points first, then each struct's methods as a group, then
standalone utility functions. Do not put a utility function between
the methods of one type.
- Put entry points first, then each struct's methods as a group, then
standalone utility functions. Do not put a utility function between
the methods of one type.
different variable only to keep or join errors.
- Use `errors.Is` and `errors.As` to examine errors. Do not compare an
error directly with a sentinel, because errors can be wrapped.
different variable only to keep or join errors.
- Use `errors.Is` and `errors.As` to examine errors. Do not compare an
error directly with a sentinel, because errors can be wrapped.
+ `errorlint` checks comparisons and type assertions on errors.
- When a function has more than one error path, wrap each returned error
with the context of its operation. A function with one error path can
- When a function has more than one error path, wrap each returned error
with the context of its operation. A function with one error path can
- return the error directly.
+ return the error directly. `wrapcheck` checks package and interface
+ calls, with the exceptions in `.golangci.yml`. Review local calls and
+ the number of error paths by hand.
- When deferred cleanup can fail, use a named `err` result and join the
cleanup error with `errors.Join`.
- When deferred cleanup can fail, use a named `err` result and join the
cleanup error with `errors.Join`.
- Put an empty line between logical blocks, also after multiline
declarations, assignments, literals, and calls. Keep an operation with
its immediate error or result check. Keep a short declaration with its
- Put an empty line between logical blocks, also after multiline
declarations, assignments, literals, and calls. Keep an operation with
its immediate error or result check. Keep a short declaration with its
+ immediate use. `wsl_v5` and `nlreturn` check part of this rule. Review
+ the remaining logical blocks and immediate-use groups by hand.
- Use GNU-style command flags: two dashes for long flags, such as
`--cwd`, and one dash only for one-letter flags, such as `-h`.
- Prefer the Go standard library. Prefer Go over cgo.
- Use GNU-style command flags: two dashes for long flags, such as
`--cwd`, and one dash only for one-letter flags, such as `-h`.
- Prefer the Go standard library. Prefer Go over cgo.
- Add tests for meaningful behavior. Do not add tests that only repeat
implementation details.
- Add tests for meaningful behavior. Do not add tests that only repeat
implementation details.
-- Use `testify/require` for assertions.
+- Use `testify/require` for assertions. `testifylint` checks the
+ assertion forms.
- Name a table-driven case slice `testCases` and its range variable
`tc`. A subtest name describes the behavior, not a generic outcome or
input.
- Name a table-driven case slice `testCases` and its range variable
`tc`. A subtest name describes the behavior, not a generic outcome or
input.