go install github.com/StevenACoffman/fixer@latest
fixer -fix ./...
golangci-lint does not currently support applying suggested fixes per golangci/golangci-lint#1779
So this just does that for us. There are a number of Khan-specific linters (written by my co-workers)
which can be enabled via -khan, so fixer -khan -fix ./...
Current golangci-linters that support SuggestedFixes:
goerr113https://github.com/Djarvur/go-err113ruleguardhttps://github.com/quasilyte/go-ruleguardnlreturnhttps://github.com/ssgreg/nlreturnexportlooprefhttps://github.com/kyoh86/exportlooprefexhaustivehttps://github.com/nishanths/exhaustivegovetstaticcheck
There's also a few in golang.org/x/tools/go/analysis:
- assign - Package assign defines an Analyzer that detects useless assignments.
- fieldaligment - Package fieldalignment defines an Analyzer that detects structs that would use less memory if their fields were sorted.
- sigchanyzer - check for unbuffered channel of os.Signal
- sortslice - Package sortslice defines an Analyzer that checks for calls to sort.Slice that do not use a slice type as first argument.
- stringintconv - Package stringintconv defines an Analyzer that flags type conversions from integers to strings.
- unreachable - Package unreachable defines an Analyzer that checks for unreachable code.
Currently, this skips findcall and rulesguard which more fiddling to get working.