Golangci-lint Configuration
golangci-lint configuration file
| Type | object |
|---|---|
| File match |
.golangci.yml
.golangci.yaml
.golangci.toml
.golangci.json
|
| Schema URL | https://catalog.lintel.tools/schemas/schemastore/golangci-lint-configuration/latest.json |
| Source | https://golangci-lint.run/jsonschema/golangci.jsonschema.json |
Versions
Validate with Lintel
npx @lintel/lintel check
Properties
Options for analysis running,
11 nested properties
Number of concurrent runners. Defaults to the number of available CPU cores.
Timeout for the analysis.
Exit code when at least one issue was found.
Enable inclusion of test files.
List of build tags to pass to all linters.
[]
Option to pass to "go list -mod={option}". See "go help modules" for more information.
Allow multiple parallel golangci-lint instances running. If disabled, golangci-lint acquires file lock on start.
Allow multiple golangci-lint instances running, but serialize them around a lock.
Targeted Go version.
Output configuration options.
5 nested properties
Output formats to use.
9 nested properties
4 nested properties
1 nested properties
3 nested properties
1 nested properties
1 nested properties
1 nested properties
2 nested properties
1 nested properties
1 nested properties
Add a prefix to the output file references.
Show statistics per linter.
5 nested properties
List of enabled linters.
List of disabled linters.
All available settings of specific linters.
86 nested properties
3 nested properties
Keywords for detecting duplicate words. If this list is not empty, only the words defined in this list will be detected.
Keywords used to ignore detection.
Checks only comments, skip strings.
2 nested properties
To specify a set of function names to exclude.
To enable/disable the asasalint builtin exclusions of function names.
9 nested properties
Disallow: LEFT-TO-RIGHT-EMBEDDING
Disallow: RIGHT-TO-LEFT-EMBEDDING
Disallow: POP-DIRECTIONAL-FORMATTING
Disallow: LEFT-TO-RIGHT-OVERRIDE
Disallow: RIGHT-TO-LEFT-OVERRIDE
Disallow: LEFT-TO-RIGHT-ISOLATE
Disallow: RIGHT-TO-LEFT-ISOLATE
Disallow: FIRST-STRONG-ISOLATE
Disallow: POP-DIRECTIONAL-ISOLATE
2 nested properties
Max complexity the function can have
Max average complexity in package
8 nested properties
[
[
"type",
"const",
"var",
"func"
]
]
Underscore vars (vars with "_" as the name) will be ignored at all checks
Order of declarations is not checked
Allow init func to be anywhere in file
Multiple global type, const and var declarations are allowed
Type declarations will be ignored for dec num check
Const declarations will be ignored for dec num check
Var declarations will be ignored for dec num check
1 nested properties
Rules to apply.
1 nested properties
Check assignments with too many blank identifiers.
1 nested properties
Tokens count to trigger issue.
2 nested properties
Checks that there is an empty space between the embedded fields and regular fields.
Checks that sync.Mutex and sync.RWMutex are not used as embedded fields.
5 nested properties
Report about not checking errors in type assertions, i.e.: a := b.(MyStruct)
Report about assignment of errors to blank identifier
List of functions to exclude from checking, where each entry is a single function to exclude
To disable the errcheck built-in exclude list
Display function signature instead of selector
2 nested properties
Issue on struct that doesn't have exported fields.
6 nested properties
Check whether fmt.Errorf uses the %w verb for formatting errors
Permit more than 1 %w verb, valid per Go 1.20
Check for plain type assertions and type switches.
Check for plain error comparisons
8 nested properties
Program elements to check for exhaustiveness.
Only run exhaustive check on switches with "//exhaustive:enforce" comment.
Only run exhaustive check on map literals with "//exhaustive:enforce" comment.
Switch statement requires default case even if exhaustive.
Presence of default case in switch statements satisfies exhaustiveness, even if all enum members are not listed.
Enum members matching regex do not have to be listed in switch statements to satisfy exhaustiveness
Enum types matching the supplied regex do not have to be listed in switch statements to satisfy exhaustiveness.
Consider enums only in package scopes, not in inner scopes.
6 nested properties
List of regular expressions to match struct packages and names.
List of regular expressions to exclude struct packages and names from check.
Allows empty structures, effectively excluding them from the check.
List of regular expressions to match type names that should be allowed to be empty.
Allows empty structures in return statements.
Allows empty structures in variable declarations.
1 nested properties
Check for potential fat contexts in struct pointers.
3 nested properties
Exclude code in godoc examples.
Instead of matching the literal source code, use type information to replace expressions with strings that contain the package name and (for methods and fields) the type name.
List of identifiers to forbid (written using regexp)
3 nested properties
Checks that constructors are placed after the structure declaration.
Checks if the exported methods of a structure are placed before the non-exported ones.
Checks if the constructors and/or structure methods are sorted alphabetically.
3 nested properties
Limit lines number per function.
Limit statements number per function.
Ignore comments when counting lines.
14 nested properties
Suppress the wrong length assertion warning.
Suppress the wrong nil assertion warning.
Suppress the wrong error assertion warning.
Suppress the wrong comparison assertion warning.
Suppress the function all in async assertion warning.
Suppress warning for comparing values from different types, like int32 and uint32.
Trigger warning for ginkgo focus containers like FDescribe, FContext, FWhen or FIt.
Don't trigger warnings for HaveLen(0).
Force using Expect with To, ToNot or NotTo
Best effort validation of async intervals (timeout and polling).
Trigger a warning for variable assignments in ginkgo containers like Describe, Context and When, instead of in BeforeEach().
Force using the Succeed matcher for error functions, and the HaveOccurred matcher for non-function error values.
Force adding assertion descriptions to gomega matchers.
Force using ToNot, ShouldNot instead of To(Not()).
2 nested properties
Presence of default case in switch statements satisfies exhaustiveness, if all members are not listed.
Include shared interfaces in the exhaustiviness check.
1 nested properties
Minimal code complexity to report (we recommend 10-20).
10 nested properties
Look for existing constants matching the values
Minimum length of string constant.
Minimum occurrences count to trigger.
Ignore when constant is not used as function argument
Exclude strings matching the given regular expression
Search also for duplicated numbers.
Minimum value, only works with numbers
Maximum value, only works with numbers
Detects constants with identical values
Evaluates of constant expressions like Prefix + "suffix"
7 nested properties
Which checks should be enabled. By default, a list of stable checks is used. To see it, run GL_DEBUG=gocritic golangci-lint run.
Enable multiple checks by tags, run GL_DEBUG=gocritic golangci-lint run to see all tags and checks.
Disable multiple checks by tags, run GL_DEBUG=gocritic golangci-lint run to see all tags and checks.
Settings passed to gocritic. Properties must be valid and enabled check names.
1 nested properties
Minimum code complexity to report (we recommend 10-20).
4 nested properties
Default set of rules to enable.
A map for setting individual rule options.
5 nested properties
Comments to be checked.
List of regexps for excluding particular comment lines from check.
Check that each sentence ends with a period.
Check that each sentence starts with a capital letter.
DEPRECATED: Check all top-level comments, not only declarations.
1 nested properties
Report any comments starting with one of these keywords. This is useful for TODO or FIXME comments that might be left in the code accidentally and should be resolved before merging.
[
"TODO",
"BUG",
"FIXME"
]
1 nested properties
The maximum number of methods allowed for an interface.
3 nested properties
Template to put on top of every file.
Path to the file containing the template source.
11 nested properties
Allow local replace directives.
List of allowed replace directives.
Allow to not explain why the version has been retracted in the retract directives.
Forbid the use of the exclude directives.
Forbid the use of the ignore directives. (>= go1.25)
Forbid the use of the toolchain directive.
Defines a pattern to validate toolchain directive.
Forbid the use of the tool directives.
Forbid the use of the godebug directive.
Defines a pattern to validate go minimum version directive.
Check the validity of the module path.
2 nested properties
6 nested properties
To select a subset of rules to run
To specify a set of rules to explicitly exclude
Filter out the issues with a lower severity than the given value
Filter out the issues with a lower confidence than the given value
To specify the configuration of rules
Concurrency value
3 nested properties
Allow and ignore time.Local usages.
List of fully qualified names in the full/pkg/path.name form, to act as "i18n escape hatches".
List of Unicode scripts to watch for any usage in string literals.
5 nested properties
Settings per analyzer. Map of analyzer name to specific settings.
Run go tool vet help to find out more.
Enable analyzers by name.
Disable analyzers by name.
Enable all analyzers.
Disable all analyzers.
8 nested properties
2 nested properties
Enable analyzers by name.
3 nested properties
Do not allow unaliased imports of aliased packages.
Do not allow non-required aliases.
List of aliases
1 nested properties
Skips check for interface methods with only a single parameter.
1 nested properties
Check escaping variables of type error, may cause false positives.
1 nested properties
Whether to report individual consts rather than just the const block.
Use either reject or allow properties for interfaces matching.
2 nested properties
2 nested properties
Width of "\t" in spaces.
Maximum allowed line length, lines longer will be reported.
Maintainability index https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022
1 nested properties
Minimum accatpable maintainability index level (see https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-maintainability-index-range-and-meaning?view=vs-2022)
1 nested properties
Allow only slices initialized with a length of zero.
8 nested properties
Allow check for the github.com/go-kit/log library.
Allow check for the k8s.io/klog/v2 library.
Allow check for the github.com/go-logr/logr library.
Allow check for the log/slog library.
Allow check for the "sugar logger" from go.uber.org/zap library.
Require all logging keys to be inlined constant strings.
Require printf-like format specifier (%s, %d for example) not present.
List of custom rules to check against, where each rule is a single logger pattern, useful for wrapped loggers.
Correct spellings using locale preferences for US or UK. Default is to use a neutral variety of English.
4 nested properties
List of rules to ignore.
Mode of the analysis.
Extra word corrections.
1 nested properties
1 nested properties
Report if a function has more lines of code than this value and it has naked returns.
1 nested properties
Minimum complexity of "if" statements to report.
3 nested properties
To check functions with only two return values.
In addition, detect opposite situation (simultaneous return of non-nil error and valid value).
List of return types to check.
[
"chan",
"func",
"iface",
"map",
"ptr",
"uintptr",
"unsafeptr"
]
1 nested properties
set block size that is still ok
4 nested properties
List of file patterns to exclude from analysis.
Comma-separated list of function patterns to exclude from the analysis.
List of numbers to exclude from analysis.
The list of enabled checks, see https://github.com/tommy-muehle/go-mnd/#checks for description.
1 nested properties
List of analyzers to disable.
4 nested properties
Enable to ensure that nolint directives are all used.
Enable to require an explanation of nonzero length after each nolint directive.
Enable to require nolint directives to mention the specific linter being suppressed.
1 nested properties
2 nested properties
Disables the built-in method exclusions.
User-defined method exclusions.
1 nested properties
Report named error if it is assigned inside defer.
2 nested properties
Ignore missing calls to t.Parallel() and only report incorrect uses of it.
Ignore missing calls to t.Parallel() in subtests. Top-level tests are still required to have t.Parallel, but subtests are allowed to skip it.
12 nested properties
Enable/disable optimization of integer formatting.
Optimizes even if it requires an int or uint type cast.
Enable/disable optimization of error formatting.
Optimizes into err.Error() even if it is only equivalent for non-nil errors.
Optimizes fmt.Errorf.
Enable/disable optimization of string formatting.
Optimizes fmt.Sprintf with only one argument.
Optimizes into strings concatenation.
Enable/disable optimization of bool formatting.
Enable/disable optimization of hex formatting.
Enable/disable optimization of concat loop.
Optimization of concat-loop even with other operations.
We do not recommend using this linter before doing performance profiling.
For most programs usage of prealloc will be premature optimization.
3 nested properties
Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
Report preallocation suggestions on range loops.
Report preallocation suggestions on for loops.
2 nested properties
List of predeclared identifiers to not report on.
Include method names and field names in checks.
2 nested properties
4 nested properties
Skip any generated files from the checking.
Skip first argument of append function.
7 nested properties
1 nested properties
11 nested properties
Enforce using key-value pairs only (incompatible with attr-only).
Enforce not using global loggers.
Enforce not mixing key-value pairs and attributes.
Enforce using methods that accept a context.
Enforce using static values for log messages.
Enforce message style.
Enforce a single key naming convention.
Enforce using attributes only (incompatible with kv-only).
Enforce using constants instead of raw keys.
Enforce not using specific keys.
Enforce putting arguments on separate lines.
3 nested properties
Checks to enable.
A list of regexes for function signatures that silence record-error and set-status reports if found in the call path to a returned error.
A list of regexes for additional function signatures that create spans.
4 nested properties
By default, ST1001 forbids all uses of dot imports in non-test packages. This setting allows setting a whitelist of import paths that can be dot-imported anywhere.
ST1013 recommends using constants from the net/http package instead of hard-coding numeric HTTP status codes. This setting specifies a list of numeric status codes that this check does not complain about.
[
"200",
"400",
"404",
"500"
]
ST1003 check, among other things, for the correct capitalization of initialisms. The set of known initialisms can be configured with this option.
4 nested properties
Align and sort can be used together or separately.
Whether enable tags sort.
Specify the order of tags, the other tags will be sorted by name.
[]
Whether enable strict style.
1 nested properties
10 nested properties
Enable all checkers.
Disable all checkers.
Enable specific checkers.
[
"blank-import",
"bool-compare",
"compares",
"contains",
"empty",
"encoded-compare",
"equal-values",
"error-is-as",
"error-nil",
"expected-actual",
"float-compare",
"formatter",
"go-require",
"len",
"negative-positive",
"nil-compare",
"regexp",
"require-error",
"suite-broken-parallel",
"suite-dont-use-pkg",
"suite-extra-assert-call",
"suite-method-signature",
"suite-subtest-run",
"useless-assert"
]
Disable specific checkers.
2 nested properties
Files with names matching this regular expression are skipped.
List of packages that don't end with _test that tests are allowed to be in.
4 nested properties
11 nested properties
Suggest the use of http.MethodXX.
Suggest the use of http.StatusXX.
Suggest the use of time.Weekday.String().
Suggest the use of time.Month.String().
Suggest the use of time.Layout.
Suggest the use of time.Month in time.Date.
Suggest the use of crypto.Hash.String().
Suggest the use of rpc.DefaultXXPath.
Suggest the use of sql.LevelXX.String().
Suggest the use of tls.SignatureScheme.String().
Suggest the use of constant.Kind.String().
7 nested properties
2 nested properties
1 nested properties
Inspect exported functions. Set to true if no external program/library imports your code.
WARNING: if you enable this setting, unparam will report a lot of false-positives in text editors: if it's called for subdir of a project it can't find external interfaces. All text editor integrations with golangci-lint call it on a directory with the changed file.
14 nested properties
Enable SQL builder checking.
Enable aliased wildcard detection like SELECT t.*.
Enable string concatenation analysis.
Enable format string analysis like fmt.Sprintf.
Enable strings.Builder analysis.
Enable subquery analysis.
Regex patterns for acceptable SELECT * usage.
Allow is a list of SQL patterns to allow (whitelist).
Functions to ignore.
6 nested properties
10 nested properties
Variables used in at most this N-many lines will be ignored.
The minimum length of a variable's name that is considered long.
Check method receiver names.
Check named return values.
Check type parameters.
Ignore ok variables that hold the bool return value of a type assertion
Ignore ok variables that hold the bool return value of a map index.
Ignore ok variables that hold the bool return value of a channel receive.
Optional list of variable names that should be ignored completely.
[
[]
]
Optional list of variable declarations that should be ignored completely.
2 nested properties
Enforces newlines (or comments) after every multi-line if statement
Enforces newlines (or comments) after every multi-line function signature
6 nested properties
An array of strings specifying additional substrings of signatures to ignore.
[
".CustomError(",
".SpecificWrap("
]
An array of strings which specify substrings of signatures to ignore.
[
".Errorf(",
"errors.New(",
"errors.Unwrap(",
".Wrap(",
".Wrapf(",
".WithMessage(",
".WithMessagef(",
".WithStack("
]
An array of strings which specify regular expressions of signatures to ignore.
[
""
]
An array of glob patterns which, if any match the package of the function returning the error, will skip wrapcheck analysis for this error.
[
""
]
An array of glob patterns which, if matched to an underlying interface name, will ignore unwrapped errors returned from a function whose call is defined on the given interface.
[
""
]
Determines whether wrapcheck should report errors returned from inside the package.
14 nested properties
Controls if you may cuddle assignments and anything without needing an empty line between them.
Allow calls and assignments to be cuddled as long as the lines have any matching variables, fields or types.
Allow declarations (var) to be cuddled.
A list of call idents that everything can be cuddled with.
AllowCuddleWithRHS is a list of right hand side variables that is allowed to be cuddled with anything.
Allow cuddling with any block as long as the variable is used somewhere in the block
Allow multiline assignments to be cuddled.
Allow leading comments to be separated with empty lines.
Allow trailing comments in ending of blocks.
When force-err-cuddling is enabled this is a list of names used for error variables to check for in the conditional.
Force newlines in end of case at this limit (0 = never).
Causes an error when an If statement that checks an error variable doesn't cuddle with the assignment of that variable.
Causes an error if a short declaration (:=) cuddles with anything other than another short declaration.
If true, append is only allowed to be cuddled if appending value is matching variables, fields or types on line above.
7 nested properties
1 nested properties
The custom section can be used to define linter plugins to be loaded at runtime. See README of golangci-lint for more information. Each custom linter should have a unique name.
6 nested properties
3 nested properties
List of enabled formatters.
5 nested properties
5 nested properties
Section configuration to compare against.
[
"standard",
"default"
]
Checks that no inline Comments are present.
Checks that no prefix Comments(comment lines above an import) are present.
Enable custom order of sections.
Drops lexical ordering for custom sections.
2 nested properties
Simplify code.
Apply the rewrite rules to the source before reformatting.
2 nested properties
Choose whether or not to use the extra rules that are disabled by default.
Module path which contains the source code being formatted.
1 nested properties
Put imports beginning with prefix after 3rd-party packages. It is a list of prefixes.
5 nested properties
3 nested properties
9 nested properties
Maximum issues count per one linter. Set to 0 to disable.
Maximum count of issues with the same text. Set to 0 to disable.
Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.
Show only new issues created after the best common ancestor (merge-base against HEAD).
Show only new issues created after this git revision.
Show only new issues created in git patch with this file path.
Apply the fixes detected by the linters and formatters (if it's supported by the linter).
Make issues output unique by line.
Show issues in any part of update files (requires new-from-rev or new-from-patch).
2 nested properties
Set the default severity for issues. If severity rules are defined and the issues do not match or no severity is provided to the rule this will be the default severity applied. Severities should match the supported severity names of the selected out format.
When a list of severity rules are provided, severity information will be added to lint issues. Severity rules have the same filtering capability as exclude rules except you are allowed to specify one matcher per severity rule. Only affects out formats that support setting severity information.
[]
Definitions
Usable linter names.
Usable formatter names.