golangci-lint

Linters

To see a list of supported linters and which linters are enabled/disabled:

golangci-lint help linters

Enabled By Default Linters

NameDescriptionPresetsAutoFixSince
deadcodeFinds unused codeunusedv1.0.0
errcheckErrcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some casesbugs, errorv1.0.0
gosimpleLinter for Go source code that specializes in simplifying a codestylev1.20.0
govetVet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format stringbugs, metalinterv1.0.0
ineffassignDetects when assignments to existing variables are not usedunusedv1.0.0
staticcheckStaticcheck is a go vet on steroids, applying a ton of static analysis checksbugs, metalinterv1.0.0
structcheckFinds unused struct fieldsunusedv1.0.0
typecheckLike the front-end of a Go compiler, parses and type-checks Go codebugsv1.3.0
unusedChecks Go code for unused constants, variables, functions and typesunusedv1.20.0
varcheckFinds unused global variables and constantsunusedv1.0.0

Disabled By Default Linters (-E/--enable)

NameDescriptionPresetsAutoFixSince
asciicheckSimple linter to check that your code does not contain non-ASCII identifiersbugs, stylev1.26.0
bodyclosechecks whether HTTP response body is closed successfullyperformance, bugsv1.18.0
cyclopchecks function and package cyclomatic complexitycomplexityv1.37.0
depguardGo linter that checks if package imports are in a list of acceptable packagesstyle, import, modulev1.4.0
dogsledChecks assignments with too many blank identifiers (e.g. x, , , _, := f())stylev1.19.0
duplTool for code clone detectionstylev1.0.0
durationcheckcheck for two durations multiplied togetherbugsv1.37.0
errorlintgo-errorlint is a source code linter for Go software that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.bugs, errorv1.32.0
exhaustivecheck exhaustiveness of enum switch statementsbugsv1.28.0
exhaustivestructChecks if all struct's fields are initializedstyle, testv1.32.0
exportlooprefchecks for pointers to enclosing loop variablesbugsv1.28.0
forbidigoForbids identifiersstylev1.34.0
forcetypeassertfinds forced type assertionsstylev1.38.0
funlenTool for detection of long functionscomplexityv1.18.0
gciGci control golang package import order and make it always deterministic.format, importv1.30.0
gochecknoglobalscheck that no global variables exist

This analyzer checks for global variables and errors on any found.

A global variable is a variable declared in package scope and that can be read
and written to by any function within the package. Global variables can cause
side effects which are difficult to keep track of. A code in one function may
change the variables state while another unrelated chunk of code may be
effected by it.
stylev1.12.0
gochecknoinitsChecks that no init functions are present in Go codestylev1.12.0
gocognitComputes and checks the cognitive complexity of functionscomplexityv1.20.0
goconstFinds repeated strings that could be replaced by a constantstylev1.0.0
gocriticProvides many diagnostics that check for bugs, performance and style issues.
Extensible without recompilation through dynamic rules.
Dynamic rules are written declaratively with AST patterns, filters, report message and optional suggestion.
style, metalinterv1.12.0
gocycloComputes and checks the cyclomatic complexity of functionscomplexityv1.0.0
godotCheck if comments end in a periodstyle, commentv1.25.0
godoxTool for detection of FIXME, TODO and other comment keywordsstyle, commentv1.19.0
goerr113Golang linter to check the errors handling expressionsstyle, errorv1.26.0
gofmtGofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplificationformatv1.0.0
gofumptGofumpt checks whether code was gofumpt-ed.formatv1.28.0
goheaderChecks is file header matches to patternstylev1.28.0
goimportsGoimports does everything that gofmt does. Additionally it checks unused importsformat, importv1.20.0
golintGolint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakesstylev1.0.0
gomndAn analyzer to detect magic numbers.stylev1.22.0
gomoddirectivesManage the use of 'replace', 'retract', and 'excludes' directives in go.mod.style, modulev1.39.0
gomodguardAllow and block list linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations.style, import, modulev1.25.0
goprintffuncnameChecks that printf-like functions are named with f at the endstylev1.23.0
gosecInspects source code for security problemsbugsv1.0.0
ifshortChecks that your code uses short syntax for if-statements whenever possiblestylev1.36.0
importasEnforces consistent import aliasesstylev1.38.0
interfacer The repository of the linter has been archived by the owner.stylev1.0.0
lllReports long linesstylev1.8.0
makezeroFinds slice declarations with non-zero initial lengthstyle, bugsv1.34.0
maligned The repository of the linter has been archived by the owner. Replaced by govet 'fieldalignment'.performancev1.0.0
misspellFinds commonly misspelled English words in commentsstyle, commentv1.8.0
nakedretFinds naked returns in functions greater than a specified function lengthstylev1.19.0
nestifReports deeply nested if statementscomplexityv1.25.0
nilerrFinds the code that returns nil even if it checks that the error is not nil.bugsv1.38.0
nlreturnnlreturn checks for a new line before return and branch statements to increase code claritystylev1.30.0
noctxnoctx finds sending http request without context.Contextperformance, bugsv1.28.0
nolintlintReports ill-formed or insufficient nolint directivesstylev1.26.0
paralleltestparalleltest detects missing usage of t.Parallel() method in your Go teststyle, testv1.33.0
preallocFinds slice declarations that could potentially be preallocatedperformancev1.19.0
predeclaredfind code that shadows one of Go's predeclared identifiersstylev1.35.0
promlinterCheck Prometheus metrics naming via promlintstylev1.40.0
reviveFast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.style, metalinterv1.37.0
rowserrcheckchecks whether Err of rows is checked successfullybugs, sqlv1.23.0
scopelint The repository of the linter has been deprecated by the owner. Replaced by exportloopref.bugsv1.12.0
sqlclosecheckChecks that sql.Rows and sql.Stmt are closed.bugs, sqlv1.28.0
stylecheckStylecheck is a replacement for golintstylev1.20.0
testpackagelinter that makes you use a separate _test packagestyle, testv1.25.0
thelperthelper detects golang test helpers without t.Helper() call and checks the consistency of test helpersstylev1.34.0
tparalleltparallel detects inappropriate usage of t.Parallel() method in your Go test codesstyle, testv1.32.0
unconvertRemove unnecessary type conversionsstylev1.0.0
unparamReports unused function parametersunusedv1.9.0
wastedassignwastedassign finds wasted assignment statements.stylev1.38.0
whitespaceTool for detection of leading and trailing whitespacestylev1.19.0
wrapcheckChecks that errors returned from external packages are wrappedstyle, errorv1.32.0
wslWhitespace Linter - Forces you to use empty lines!stylev1.20.0
Edit this page on GitHub