Custom Go linters, usable via go vet -vettool or as golangci-lint module plugins.
| Name | Description | Load Mode |
|---|---|---|
println |
Reports println builtin usage |
syntax |
printf |
Reports fmt.(Fp|P)rintf* usage (Fprint only flags os.Stdout) |
syntax |
uselessf |
Reports *f calls with no format args (e.g. Errorf("msg") → errors.New) |
syntax |
deferfor |
Reports defer directly inside a for loop |
syntax |
errresp |
Reports ErrorResponse() not immediately followed by return |
syntax |
mustcheck |
Reports .MustVerb() zero-arg calls outside init and package-level declarations |
syntax |
fatal |
Reports Logger.Fatal* calls |
types |
Each linter has a standalone binary under cmd/:
go build -o println-checker ./cmd/println
go vet -vettool=./println-checker ./...Or use the combined binary for all linters at once:
go build -o combined-checker ./cmd/combined
go vet -vettool=./combined-checker ./...Requires golangci-lint v2. See testproject/ for a working example.
This tells golangci-lint to build a custom binary with the plugin:
version: v2.10.1
plugins:
- module: 'github.com/edaniels/golinters'
version: v0.2.0 # or use path: ../golinters for local devEnable whichever linters you want:
version: "2"
linters:
enable:
- println
- printf
- uselessf
- deferfor
- errresp
- mustcheck
- fatal
settings:
custom:
println:
type: module
printf:
type: module
uselessf:
type: module
deferfor:
type: module
errresp:
type: module
mustcheck:
type: module
fatal:
type: modulegolangci-lint custom # builds ./custom-gcl
./custom-gcl run ./... # run like normal golangci-lint