# Options for analysis running. run: # Timeout for analysis, e.g. 30s, 5m. # Default: 1m timeout: 10m # Exit code when at least one issue was found. # Default: 1 issues-exit-code: 1 # Include test files or not. # Default: true tests: true # List of build tags, all linters use it. # Default: []. build-tags: [ ] # Which dirs to skip: issues from them won't be reported. # Can use regexp here: `generated.*`, regexp is applied on full path, # including the path prefix if one is set. # Default value is empty list, # but default dirs are skipped independently of this option's value (see skip-dirs-use-default). # "/" will be replaced by current OS file path separator to properly work on Windows. skip-dirs: - pkg/ - migrations/ # If set we pass it to "go list -mod={option}". From "go help modules": # If invoked with -mod=readonly, the go command is disallowed from the implicit # automatic updating of go.mod described above. Instead, it fails when any changes # to go.mod are needed. This setting is most useful to check that go.mod does # not need updates, such as in a continuous integration and testing system. # If invoked with -mod=vendor, the go command assumes that the vendor # directory holds the correct copies of dependencies and ignores # the dependency descriptions in go.mod. # # Allowed values: readonly|vendor|mod # By default, it isn't set. modules-download-mode: readonly # Allow multiple parallel golangci-lint instances running. allow-parallel-runners: true output: sort-results: true linters: enable: - asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers - containedctx # containedctx is a linter that detects struct contained context.Context field - cyclop # checks function and package cyclomatic complexity - dupl # Tool for code clone detection - errname # Checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error` - errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13 - exhaustive # check exhaustiveness of enum switch statements - exhaustruct # Checks if all structure fields are initialized - funlen # Tool for detection of long functions - gocognit # Computes and checks the cognitive complexity of functions - goconst # Finds repeated strings that could be replaced by a constant - gocritic # Provides diagnostics that check for bugs, performance and style issues - lll # Reports long lines - makezero # Finds slice declarations with non-zero initial length - nilerr # Finds the code that returns nil even if it checks that the error is not nil - prealloc # Finds slice declarations that could potentially be pre-allocated - tagliatelle # Checks the struct tags # TODO: consider following linters # - fieldalignment # - wrapcheck linters-settings: cyclop: # The maximal code complexity to report. # Default: 10 max-complexity: 10 # The maximal average package complexity. # If it's higher than 0.0 (float) the check is enabled # Default: 0.0 package-average: 0.0 # Should ignore tests. # Default: false skip-tests: true dupl: # Tokens count to trigger issue. # Default: 150 threshold: 150 errorlint: # Check whether fmt.Errorf uses the %w verb for formatting errors. # See the https://github.com/polyfloyd/go-errorlint for caveats. # Default: true errorf: true # Permit more than 1 %w verb, valid per Go 1.20 (Requires errorf:true) # Default: true errorf-multi: true # Check for plain type assertions and type switches. # Default: true asserts: true # Check for plain error comparisons. # Default: true comparison: true exhaustruct: # List of regular expressions to exclude struct packages and names from check. # Default: [] exclude: # public libs - "^github.com/segmentio/kafka-go.Message$" exhaustive: # Program elements to check for exhaustiveness. # Default: [ switch ] check: - switch # - map # Check switch statements in generated files also. # Default: false check-generated: false # Presence of "default" case in switch statements satisfies exhaustiveness, # even if all enum members are not listed. # Default: false default-signifies-exhaustive: false # Enum members matching the supplied regex do not have to be listed in # switch statements to satisfy exhaustiveness. # Default: "" ignore-enum-members: "Example.+" # Enum types matching the supplied regex do not have to be listed in # switch statements to satisfy exhaustiveness. # Default: "" ignore-enum-types: "Example.+" # Consider enums only in package scopes, not in inner scopes. # Default: false package-scope-only: false # Only run exhaustive check on switches with "//exhaustive:enforce" comment. # Default: false explicit-exhaustive-switch: false # Only run exhaustive check on map literals with "//exhaustive:enforce" comment. # Default: false explicit-exhaustive-map: false funlen: # Checks the number of lines in a function. # If lower than 0, disable the check. # Default: 60 lines: 60 # Checks the number of statements in a function. # If lower than 0, disable the check. # Default: 40 statements: 40 gocognit: # Minimal code complexity to report. # Default: 30 min-complexity: 30 goconst: # Minimal length of string constant. # Default: 3 min-len: 3 # Minimum occurrences of constant string count to trigger issue. # Default: 3 min-occurrences: 3 # Ignore test files. # Default: false ignore-tests: true # Look for existing constants matching the values. # Default: true match-constant: true # Search also for duplicated numbers. # Default: false numbers: false # Ignore when constant is not used as function argument. # Default: true ignore-calls: true gocritic: # Which checks should be enabled; can't be combined with 'disabled-checks'. # See https://go-critic.github.io/overview#checks-overview. # To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`. # By default, list of stable checks is used. enabled-checks: - appendAssign - appendCombine - badCond - badLock - badRegexp - boolExprSimplify - builtinShadow - builtinShadowDecl - captLocal - caseOrder - commentFormatting - commentedOutCode - commentedOutImport - defaultCaseOrder - deferInLoop - deferUnlambda - deprecatedComment - docStub - dupArg - dupBranchBody - dupCase - dupImport - dupSubExpr - dynamicFmtString - elseif - emptyDecl - emptyFallthrough - emptyStringTest - exposedSyncMutex - externalErrorReassign - filepathJoin - flagDeref - flagName - hugeParam - ifElseChain - indexAlloc - mapKey - nestingReduce - nilValReturn - octalLiteral - offBy1 - preferDecodeRune - preferFilepathJoin - ptrToRefParam - rangeExprCopy - rangeValCopy - regexpMust - regexpSimplify - singleCaseSwitch - sliceClear - sloppyLen - sloppyReassign - sloppyTypeAssert - stringConcatSimplify - stringXbytes - stringsCompare - switchTrue - timeCmpSimplify - timeExprSimplify - truncateCmp - typeAssertChain - typeDefFirst - typeSwitchVar - typeUnparen - uncheckedInlineErr - underef - unlambda - unnecessaryDefer - weakCond - whyNoLint - wrapperFunc - yodaStyleExpr # Settings passed to gocritic. # The settings key is the name of a supported gocritic checker. # The list of supported checkers can be find in https://go-critic.github.io/overview. settings: # Must be valid enabled check name. captLocal: # Whether to restrict checker to params only. # Default: true paramsOnly: true elseif: # Whether to skip balanced if-else pairs. # Default: true skipBalanced: true hugeParam: # Size in bytes that makes the warning trigger. # Default: 80 sizeThreshold: 512 nestingReduce: # Min number of statements inside a branch to trigger a warning. # Default: 5 bodyWidth: 3 rangeExprCopy: # Size in bytes that makes the warning trigger. # Default: 512 sizeThreshold: 512 # Whether to check test functions # Default: true skipTestFuncs: true rangeValCopy: # Size in bytes that makes the warning trigger. # Default: 128 sizeThreshold: 128 # Whether to check test functions. # Default: true skipTestFuncs: true truncateCmp: # Whether to skip int/uint/uintptr types. # Default: true skipArchDependent: true underef: # Whether to skip (*x).method() calls where x is a pointer receiver. # Default: true skipRecvDeref: true prealloc: # IMPORTANT: we don't recommend using this linter before doing performance profiling. # For most programs usage of prealloc will be a premature optimization. # Report pre-allocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them. # Default: true simple: true # Report pre-allocation suggestions on range loops. # Default: true range-loops: true # Report pre-allocation suggestions on for loops. # Default: false for-loops: true tagliatelle: # Check the struct tag name case. case: # Use the struct field name to check the name of the struct tag. # Default: false use-field-name: false # `camel` is used for `json` and `yaml`, and `header` is used for `header` (can be overridden) # Default: {} rules: # Any struct tag type can be used. # Support string case: `camel`, `pascal`, `kebab`, `snake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header` db: snake json: camel yaml: camel mapstructure: camel # xml: camel # TODO issues: # List of regexps of issue texts to exclude. # # Independently of option `exclude` we use default exclude patterns, # it can be disabled by this option. # To list all excluded by default patterns execute `golangci-lint run --help`. # Default: true. exclude-use-default: true # Excluding configuration per-path, per-linter, per-text and per-source exclude-rules: # Exclude `lll` and `gocritic` issues for long lines with `go:generate` - source: "^//go:generate " linters: - lll - gocritic # Exclude `lll` issues for long struct tags - source: "`[^`\n]+`" linters: - lll # Exclude `lll` issues for swagger annotation - source: "^//[\\s]*@[\\w]+\\s+" linters: - lll # Exclude `lll` issues for long lines with `swag annotations` - linters: - lll source: "^//[\\s]*@" # Exclude `lll` and `funlen` for test files - path: _test\.go linters: - funlen - lll - containedctx - exhaustruct