golangci / golangci-lint

Fast linters runner for Go
https://golangci-lint.run
GNU General Public License v3.0
15.27k stars 1.36k forks source link

Intrange: panic #4720

Closed TariqRWW closed 3 months ago

TariqRWW commented 3 months ago

Welcome

Description of the problem

I don't quite understand, but for some reason when I try to lint the example code provided, the goanalysis_metalinter panics and fails to run.

Version of golangci-lint

```console $ golangci-lint --version golangci-lint has version 1.57.2 built with go1.22.1 from 77a8601 on 2024-03-28T18:39:06Z ```

Configuration

```yaml run: timeout: 4m issues-exit-code: 1 tests: true build-tags: [] skip-dirs: skip-dirs-use-default: true skip-files: - ".*\\_gen\\.go$" - ".*\\.pb\\.go$" allow-parallel-runners: false output: format: colored-line-number print-issued-lines: true print-linter-name: true uniq-by-line: true path-prefix: "" sort-results: true # All available settings of specific linters. linters-settings: asasalint: exclude: - append - Append - \.Wrapf use-builtin-exclusions: true ignore-test: false bidichk: left-to-right-embedding: false right-to-left-embedding: false pop-directional-formatting: false left-to-right-override: false right-to-left-override: false left-to-right-isolate: false right-to-left-isolate: false first-strong-isolate: false pop-directional-isolate: false cyclop: max-complexity: 20 package-average: 0.0 skip-tests: false decorder: dec-order: - type - const - var - func ignore-underscore-vars: false disable-dec-order-check: false disable-init-func-first-check: false disable-dec-num-check: false disable-type-dec-num-check: false disable-const-dec-num-check: false disable-var-dec-num-check: false depguard: rules: # Name of a rule. main: list-mode: original files: - "!**/*_a _file.go" allow: - $gostd - github.com/OpenPeeDeeP deny: - pkg: "github.com/sirupsen/logrus" desc: not allowed - pkg: "github.com/pkg/errors" desc: Should be replaced by standard lib errors package dogsled: max-blank-identifiers: 2 dupl: threshold: 100 dupword: keywords: [] ignore: [] errcheck: check-type-assertions: true check-blank: true disable-default-exclusions: false exclude-functions: - io/ioutil.ReadFile - io.Copy(*bytes.Buffer) - io.Copy(os.Stdout) - (*go.uber.org/zap.Logger).Sync - encoding/json.Marshal # see errchkjson - encoding/json.MarshalIndent # see errchkjson - (net/http.ResponseWriter).Write - (io.ReadCloser).Close # to suppress resp.Body.Close() error checking errchkjson: check-error-free-encoding: true # Issue on struct encoding that doesn't have exported fields. report-no-exported: true errorlint: errorf: true errorf-multi: true asserts: true comparison: true exhaustive: check: - switch - map check-generated: false default-signifies-exhaustive: true ignore-enum-members: "Example.+" ignore-enum-types: "Example.+" package-scope-only: false explicit-exhaustive-switch: false explicit-exhaustive-map: false default-case-required: false exhaustivestruct: struct-patterns: - "*.Test" - "example.com/package.ExampleStruct" exhaustruct: include: - '.+\.Test' - 'example\.com/package\.ExampleStruct[\d]{1,2}' exclude: - '.+/cobra\.Command$' forbidigo: forbid: # Builtin function: - "^(fmt\\.Print(|f|ln)|print|println)$" - ^spew\.(ConfigState\.)?Dump$ exclude-godoc-examples: true analyze-types: false funlen: lines: 80 statements: 40 ignore-comments: true gci: sections: - standard # Standard section: captures all standard packages. - default # Default section: contains all imports that could not be matched to another section type. - prefix() # Custom section: groups all imports with the specified Prefix. - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. skip-generated: true custom-order: false ginkgolinter: suppress-len-assertion: true suppress-nil-assertion: true suppress-err-assertion: true suppress-compare-assertion: false suppress-async-assertion: false suppress-type-compare-assertion: false forbid-focus-container: false allow-havelen-zero: false gocognit: min-complexity: 20 goconst: min-len: 3 min-occurrences: 2 ignore-tests: false match-constant: true numbers: false min: 3 max: 3 ignore-calls: true ignore-strings: "" gocritic: disabled-checks: - paramTypeCombine enabled-tags: - diagnostic - style - performance - experimental - opinionated settings: captLocal: paramsOnly: false elseif: skipBalanced: false hugeParam: sizeThreshold: 256 nestingReduce: bodyWidth: 5 rangeExprCopy: sizeThreshold: 512 skipTestFuncs: false rangeValCopy: sizeThreshold: 128 skipTestFuncs: true tooManyResultsChecker: maxResults: 5 truncateCmp: skipArchDependent: false underef: skipRecvDeref: false unnamedResult: checkExported: true gocyclo: min-complexity: 20 godot: scope: toplevel exclude: - "^fixme:" - "^todo:" period: false capital: true godox: keywords: - BUG - FIXME gofmt: simplify: true rewrite-rules: - pattern: "interface{}" replacement: "any" - pattern: "a[b:len(a)]" replacement: "a[b:]" - pattern: "[]T{T{}, T{}}" replacement: "[]T{{}, {}}" gofumpt: module-path: gitlab.co.uk extra-rules: false goheader: values: const: COMPANY: MY COMPANY regexp: AUTHOR: .*@mycompany\.com template: |- # Put here copyright header template for source code files # For example: # Note: {{ YEAR }} is a builtin value that returns the year relative to the current machine time. # # {{ AUTHOR }} {{ COMPANY }} {{ YEAR }} # SPDX-License-Identifier: Apache-2.0 # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. template-path: /path/to/my/template.tmpl goimports: local-prefixes: gitlab.co.uk golint: min-confidence: 0.8 gomnd: checks: - argument - case - condition - operation - return - assign ignored-numbers: ["2", "0666", "0755", "42"] ignored-files: [] ignored-functions: [] gomoddirectives: replace-local: false replace-allow-list: [] retract-allow-no-explanation: false exclude-forbidden: false gomodguard: allowed: modules: [] domains: [] blocked: modules: - github.com/uudashr/go-module: recommendations: - golang.org/x/mod reason: "`mod` is the official go.mod parser library." versions: - github.com/mitchellh/go-homedir: version: "< 1.1.0" reason: "testing if blocked version constraint works." local_replace_directives: false gosimple: checks: ["all"] gosec: includes: - G101 # Look for hard coded credentials - G102 # Bind to all interfaces - G103 # Audit the use of unsafe block - G104 # Audit errors not checked - G106 # Audit the use of ssh.InsecureIgnoreHostKey - G107 # Url provided to HTTP request as taint input - G108 # Profiling endpoint automatically exposed on /debug/pprof - G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32 - G110 # Potential DoS vulnerability via decompression bomb - G111 # Potential directory traversal - G112 # Potential slowloris attack - G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772) - G114 # Use of net/http serve function that has no support for setting timeouts - G201 # SQL query construction using format string - G202 # SQL query construction using string concatenation - G203 # Use of unescaped data in HTML templates - G204 # Audit use of command execution - G301 # Poor file permissions used when creating a directory - G302 # Poor file permissions used with chmod - G303 # Creating tempfile using a predictable path - G304 # File path provided as taint input - G305 # File traversal when extracting zip/tar archive - G306 # Poor file permissions used when writing to a new file - G307 # Poor file permissions used when creating a file with os.Create - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - G402 # Look for bad TLS connection settings - G403 # Ensure minimum RSA key length of 2048 bits - G404 # Insecure random number source (rand) - G501 # Import blocklist: crypto/md5 - G502 # Import blocklist: crypto/des - G503 # Import blocklist: crypto/rc4 - G504 # Import blocklist: net/http/cgi - G505 # Import blocklist: crypto/sha1 - G601 # Implicit memory aliasing of items from a range statement - G602 # Slice access out of bounds excludes: [] exclude-generated: true severity: medium confidence: medium config: global: nosec: true show-ignored: true audit: true G101: pattern: "(?i)passwd|pass|password|pwd|secret|token|pw|apiKey|bearer|cred" ignore_entropy: false entropy_threshold: "80.0" per_char_threshold: "3.0" truncate: "32" G104: fmt: - Fscanf G111: pattern: "http\\.Dir\\(\"\\/\"\\)|http\\.Dir\\('\\/'\\)" G301: "0750" G302: "0600" G306: "0600" gosmopolitan: allow-time-local: false escape-hatches: [] ignore-tests: false watch-for-scripts: - Devanagari - Han - Hangul - Hiragana - Katakana govet: check-shadowing: true settings: printf: funcs: - (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof - (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf - (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf - (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf shadow: strict: false unusedresult: funcs: [] stringmethods: [] disable-all: false enable: - appends - asmdecl - assign - atomic - atomicalign - bools - buildtag - cgocall - composites - copylocks - deepequalerrors - defers - directive - errorsas # - fieldalignment # prefer readability over micro-performance optimizations - findcall - framepointer - httpresponse - ifaceassert - loopclosure - lostcancel - nilfunc - nilness - printf - reflectvaluecompare - shadow - shift - sigchanyzer - slog - sortslice - stdmethods - stringintconv - structtag - testinggoroutine - tests - unmarshal - unreachable - unsafeptr - unusedresult - unusedwrite enable-all: false disable: [] grouper: const-require-single-const: false const-require-grouping: false import-require-single-import: true import-require-grouping: true type-require-single-type: false type-require-grouping: false var-require-single-var: false var-require-grouping: false ifshort: max-decl-lines: 1 max-decl-chars: 80 importas: no-unaliased: true no-extra-aliases: true alias: - pkg: knative.dev/serving/pkg/apis/serving/v1 alias: servingv1 - pkg: knative.dev/serving/pkg/apis/autoscaling/v1alpha1 alias: autoscalingv1alpha1 - pkg: knative.dev/serving/pkg/apis/(\w+)/(v[\w\d]+) alias: $1$2 interfacebloat: max: 5 ireturn: allow: - anon - error - empty - stdlib - (or|er)$ - Option - Tx - Notification - gitlab.co.uk/payments/payrun-mc-subgraph/internal/server/graph/models - gitlab.co.uk/payments/payrun-mc-subgraph/internal/server/graph/resolvers lll: line-length: 120 tab-width: 1 loggercheck: kitlog: false klog: false logr: false zap: false require-string-key: true no-printf-like: true rules: maintidx: under: 100 makezero: always: false maligned: suggest-new: true misspell: locale: UK ignore-words: [] musttag: functions: - name: github.com/jmoiron/sqlx.Get tag: db arg-pos: 1 nakedret: max-func-lines: 30 nestif: min-complexity: 4 nilnil: checked-types: - ptr - func - iface - map - chan nlreturn: block-size: 2 nolintlint: allow-unused: false allow-no-explanation: [] require-explanation: true require-specific: true nonamedreturns: report-error-in-defer: false paralleltest: ignore-missing: false ignore-missing-subtests: true prealloc: simple: true range-loops: true for-loops: false predeclared: ignore: "" q: true promlinter: strict: false disabled-linters: [] protogetter: skip-generated-by: [] skip-files: [] skip-any-generated: false reassign: patterns: - ".*" revive: ignore-generated-header: true severity: error enable-all-rules: false confidence: 0.8 rules: - name: add-constant disabled: true arguments: - maxLitCount: "1" allowStrs: '"0666", "0755", "42"' allowInts: "0,1,2,42" allowFloats: "0.0,0.,1.0,1.,2.0,2." - name: argument-limit arguments: [5] - name: atomic - name: banned-characters arguments: ["Ω", "Σ", "σ", "7"] - name: bare-return - name: blank-imports - name: bool-literal-in-expr - name: call-to-gc - name: cognitive-complexity disabled: true arguments: [20] - name: comment-spacings severity: error disabled: false arguments: - nolint - name: confusing-naming - name: confusing-results severity: warning disabled: true - name: constant-logical-expr - name: context-as-argument arguments: - allowTypesBefore: "*testing.T,*github.com/user/repo/testing.Harness" - name: context-keys-type - name: cyclomatic arguments: [20] - name: datarace - name: deep-exit - name: defer arguments: [ [ "call-chain", "loop", "method-call", "recover", "immediate-recover", "return", ], ] - name: dot-imports - name: duplicated-imports - name: early-return arguments: - "preserveScope" - name: empty-block - name: empty-lines - name: enforce-map-style arguments: - "make" - name: error-naming - name: error-return - name: error-strings - name: errorf severity: warning disabled: true - name: exported disabled: true - name: file-header disabled: true - name: flag-parameter severity: warning disabled: true - name: function-result-limit arguments: [5] - name: function-length disabled: true arguments: [40, 80] - name: get-return - name: identical-branches - name: if-return - name: increment-decrement - name: indent-error-flow arguments: - "preserveScope" - name: import-alias-naming severity: warning disabled: false arguments: - "^[a-z][a-z0-9]{0,}$" - name: imports-blacklist disabled: true - name: import-shadowing - name: line-length-limit disabled: true arguments: [120] - name: max-public-structs disabled: true arguments: [5] - name: modifies-parameter severity: warning disabled: true - name: modifies-value-receiver severity: warning disabled: true - name: nested-structs severity: warning disabled: true - name: optimize-operands-order severity: warning disabled: true - name: package-comments disabled: true - name: range - name: range-val-in-closure - name: range-val-address - name: receiver-naming - name: redundant-import-alias disabled: true - name: redefines-builtin-id - name: string-of-int - name: string-format arguments: - - "core.WriteError[1].Message" - "/^([^A-Z]|$)/" - must not start with a capital letter - - "fmt.Errorf[0]" - '/(^|[^\.!?])$/' - must not end in punctuation - - panic - '/^[^\n]*$/' - must not contain line breaks # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#struct-tag - name: struct-tag # arguments: # - "json,inline" # - "bson,outline,gnu" # severity: warning # disabled: false # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#superfluous-else # similar to elseif in gocritic and indent-error-flow in revive - name: superfluous-else # severity: warning # disabled: false arguments: - "preserveScope" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-equal - name: time-equal # severity: warning # disabled: false # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#time-naming - name: time-naming severity: warning # TODO: enable with warning level when https://github.com/golangci/golangci-lint/issues/3111 is fixed disabled: true # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming - name: var-naming # severity: warning disabled: true arguments: - ["ID"] # AllowList - ["VM"] # DenyList # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-declaration - name: var-declaration # severity: warning # disabled: false # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unconditional-recursion - name: unconditional-recursion # severity: warning # disabled: false # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-naming - name: unexported-naming # severity: warning # disabled: false # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return - name: unexported-return # severity: warning # disabled: false # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unhandled-error # similar to errcheck and G101 in gosec - name: unhandled-error # severity: warning # TODO: enable when https://github.com/golangci/golangci-lint/issues/2706 is implemented, until then we only use errcheck disabled: true arguments: - "fmt.Printf" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unnecessary-stmt - name: unnecessary-stmt # severity: warning # disabled: false # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unreachable-code - name: unreachable-code # severity: warning # disabled: false # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter - name: unused-parameter # severity: warning # disabled: false arguments: - allowRegex: "^_" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-receiver - name: unused-receiver # severity: warning # TODO: enable with warning level when https://github.com/golangci/golangci-lint/issues/3111 is fixed disabled: true arguments: - allowRegex: "^_" # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#useless-break # similar to unnecessary-stmt in revive - name: useless-break # severity: warning # disabled: false # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#waitgroup-by-value - name: waitgroup-by-value # severity: warning # disabled: false rowserrcheck: # database/sql is always checked # Default: [] # TODO: extend the list as required packages: - github.com/go-sql-driver/mysql - github.com/jackc/pgx/v4 - github.com/jackc/pgx/v5 - github.com/jinzhu/gorm/dialects/mysql - github.com/jinzhu/gorm/dialects/postgres - github.com/jinzhu/gorm/dialects/sqlite - github.com/jmoiron/sqlx - github.com/lib/pq - github.com/mattn/go-sqlite3 sloglint: # Enforce using key-value pairs only (incompatible with attr-only). # Default: false kv-only: true # Enforce using attributes only (incompatible with kv-only). # Default: false attr-only: false # Enforce using methods that accept a context. # Default: false context-only: false # Enforce using static values for log messages. # Default: false static-msg: true # Enforce using constants instead of raw keys. # Default: false no-raw-keys: false # Enforce a single key naming convention. # Values: snake, kebab, camel, pascal # Default: "" key-naming-case: snake # Enforce putting arguments on separate lines. # Default: false args-on-sep-lines: false staticcheck: # Select the Go version to target. # Default: "1.13" # Deprecated: use the global `run.go` instead. # go: "1.17" # SAxxxx checks in https://staticcheck.io/docs/configuration/options/#checks # Default: ["*"] checks: ["all"] stylecheck: # Select the Go version to target. # Default: 1.13 # Deprecated: use the global `run.go` instead. # go: "1.17" # STxxxx checks in https://staticcheck.io/docs/configuration/options/#checks # Default: ["*"] checks: ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1020", "-ST1021", "-ST1022"] # https://staticcheck.io/docs/configuration/options/#dot_import_whitelist # Default: ["github.com/mmcloughlin/avo/build", "github.com/mmcloughlin/avo/operand", "github.com/mmcloughlin/avo/reg"] dot-import-whitelist: ["https://github.com/onsi/ginkgo"] # https://staticcheck.io/docs/configuration/options/#initialisms # Default: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"] # similar to string-format in revive and var-naming in revive initialisms: [ "ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS", ] # https://staticcheck.io/docs/configuration/options/#http_status_code_whitelist # Default: ["200", "400", "404", "500"] http-status-code-whitelist: ["200", "400", "404", "500"] tagalign: # Align and sort can be used together or separately. # # Whether enable align. If true, the struct tags will be aligned. # eg: # type FooBar struct { # Bar string `json:"bar" validate:"required"` # FooFoo int8 `json:"foo_foo" validate:"required"` # } # will be formatted to: # type FooBar struct { # Bar string `json:"bar" validate:"required"` # FooFoo int8 `json:"foo_foo" validate:"required"` # } # Default: true. align: true # Whether enable tags sort. # If true, the tags will be sorted by name in ascending order. # eg: `xml:"bar" json:"bar" validate:"required"` -> `json:"bar" validate:"required" xml:"bar"` # Default: true sort: true # Specify the order of tags, the other tags will be sorted by name. # This option will be ignored if `sort` is false. # Default: [] order: - db - json - yaml - yml - toml - mapstructure - binding - validate # order for https://github.com/kelseyhightower/envconfig#struct-tag-support - envconfig - default - required # Whether enable strict style. # In this style, the tags will be sorted and aligned in the dictionary order, # and the tags with the same name will be aligned together. # Note: This option will be ignored if 'align' or 'sort' is false. # Default: false strict: false 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`, `upperSnake`, `goCamel`, `goPascal`, `goKebab`, `goSnake`, `upper`, `lower`, `header` json: camel yaml: camel xml: camel bson: camel avro: snake mapstructure: kebab env: upperSnake envconfig: upperSnake tenv: # The option `all` will run against whole test files (`_test.go`) regardless of method/function signatures. # Otherwise, only methods that take `*testing.T`, `*testing.B`, and `testing.TB` as arguments are checked. # Default: false all: true testifylint: # Enable all checkers (https://github.com/Antonboom/testifylint#checkers). # Default: false enable-all: true # Disable checkers by name # (in addition to default # suite-thelper # ). # disable: # - bool-compare # - compares # - empty # - error-is-as # - error-nil # - expected-actual # - go-require # - float-compare # - len # - nil-compare # - require-error # - suite-dont-use-pkg # - suite-extra-assert-call # - suite-thelper # Disable all checkers (https://github.com/Antonboom/testifylint#checkers). # Default: false # disable-all: true # Enable checkers by name # (in addition to default # bool-compare, compares, empty, error-is-as, error-nil, expected-actual, go-require, float-compare, len, # nil-compare, require-error, suite-dont-use-pkg, suite-extra-assert-call # ). # enable: # - bool-compare # - compares # - empty # - error-is-as # - error-nil # - expected-actual # - go-require # - float-compare # - len # - nil-compare # - require-error # - suite-dont-use-pkg # - suite-extra-assert-call # - suite-thelper expected-actual: # Regexp for expected variable name. # Default: (^(exp(ected)?|want(ed)?)([A-Z]\w*)?$)|(^(\w*[a-z])?(Exp(ected)?|Want(ed)?)$) pattern: ^expected require-error: # Regexp for assertions to analyze. If defined then only matched assertions will be reported. # Default: "" fn-pattern: ^(Errorf?|NoErrorf?)$ suite-extra-assert-call: # To require or remove extra Assert() call? # Default: remove mode: require testpackage: # Regexp pattern to skip files. # Default: "(export|internal)_test\\.go" skip-regexp: (export|internal)_test\.go # List of packages that don't end with _test that tests are allowed to be in. # Default: "main" allow-packages: - main thelper: test: # Check *testing.T is first param (or after context.Context) of helper function. # Default: true first: true # Check *testing.T param has name t. # Default: true name: true # Check t.Helper() begins helper function. # Default: true begin: true benchmark: # Check *testing.B is first param (or after context.Context) of helper function. # Default: true first: true # Check *testing.B param has name b. # Default: true name: true # Check b.Helper() begins helper function. # Default: true begin: true tb: # Check *testing.TB is first param (or after context.Context) of helper function. # Default: true first: true # Check *testing.TB param has name tb. # Default: true name: true # Check tb.Helper() begins helper function. # Default: true begin: true fuzz: # Check *testing.F is first param (or after context.Context) of helper function. # Default: true first: true # Check *testing.F param has name f. # Default: true name: true # Check f.Helper() begins helper function. # Default: true begin: true usestdlibvars: # Suggest the use of http.MethodXX. # Default: true http-method: true # Suggest the use of http.StatusXX. # Default: true http-status-code: true # Suggest the use of time.Weekday.String(). # Default: true time-weekday: true # Suggest the use of time.Month.String(). # Default: false time-month: true # Suggest the use of time.Layout. # Default: false time-layout: true # Suggest the use of crypto.Hash.String(). # Default: false crypto-hash: true # Suggest the use of rpc.DefaultXXPath. # Default: false default-rpc-path: true # DEPRECATED Suggest the use of os.DevNull. # Default: false os-dev-null: true # Suggest the use of sql.LevelXX.String(). # Default: false sql-isolation-level: true # Suggest the use of tls.SignatureScheme.String(). # Default: false tls-signature-scheme: true # Suggest the use of constant.Kind.String(). # Default: false constant-kind: true # DEPRECATED Suggest the use of syslog.Priority. # Default: false syslog-priority: true # similar to unused-parameter in revive unparam: # Inspect exported functions. # # Set to true if no external program/library imports your code. # XXX: 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. # # Default: false check-exported: false unused: # Mark all struct fields that have been written to as used. # Default: true field-writes-are-uses: false # Treat IncDec statement (e.g. `i++` or `i--`) as both read and write operation instead of just write. # Default: false post-statements-are-reads: false # Mark all exported identifiers as used. # Default: true exported-is-used: true # Mark all exported fields as used. # default: true exported-fields-are-used: true # Mark all function parameters as used. # default: true parameters-are-used: true # Mark all local variables as used. # default: true local-variables-are-used: false # Mark all identifiers inside generated files as used. # Default: true generated-is-used: true varcheck: # Check usage of exported fields and variables. # Default: false exported-fields: false varnamelen: max-distance: 30 min-name-length: 3 check-receiver: false check-return: true check-type-param: true ignore-type-assert-ok: true ignore-map-index-ok: true ignore-chan-recv-ok: true ignore-names: - dt - err - id - mc - sc - to - tx ignore-decls: - c echo.Context - t testing.T - f *foo.Bar - e error - i int - const C - T any - m map[string]int - w http.ResponseWriter - r *http.Request - s *Service - wg sync.WaitGroup - g *errgroup.Group whitespace: multi-if: false multi-func: false wrapcheck: ignoreSigs: - .Errorf( - errors.New( - errors.Unwrap( - .Wrap( - .Wrapf( - .WithMessage( - .WithMessagef( - .WithStack( - args.Error( # for 'args.Error(' in mocks - status.Error( ignoreSigRegexps: - \.New.*Error\( ignorePackageGlobs: - encoding/* - github.com/pkg/* ignoreInterfaceRegexps: - ^(?i)c(?-i)ach(ing|e) wsl: strict-append: true allow-assign-and-call: true allow-assign-and-anything: false allow-multiline-assign: true force-case-trailing-whitespace: 0 allow-trailing-comment: false allow-separated-leading-comment: false allow-cuddle-declarations: false allow-cuddle-with-calls: ["Lock", "RLock"] allow-cuddle-with-rhs: ["Unlock", "RUnlock"] force-err-cuddling: false error-variable-names: ["err"] force-short-decl-cuddling: false linters: # Disable all linters. # Default: false disable-all: false # Enable specific linter # https://golangci-lint.run/usage/linters/#enabled-by-default enable: [] # Enable all available linters. # Default: false enable-all: true # Disable specific linter # https://golangci-lint.run/usage/linters/#disabled-by-default disable: - decorder # wouldn't work well with cases where we want to keep type definitions close together with their methods (see models.go) - depguard # we have no fear of any dependencies - dupl # not convenient for us - exhaustivestruct # replaced by exhaustruct - exhaustruct # we are happy to rely on default init values - gci # enable when https://github.com/golangci/golangci-lint/issues/1490 is fixed - godot # - goheader # we don't use copyright headers - golint # deprecated, use staticcheck and go vet instead - gomodguard # freedom to choose your packages - importas # would be great for baseLogger, protorepo, etc... - interfacebloat # we do have fat interfaces - interfacer # deprecated, not sure if we gain many benefits from this - loggercheck # doesn't seem useful for us, we don't use zap's sugar logger - maintidx # seems to be still experimental - maligned # prefer readability over micro-performance optimizations - musttag # many times we just want to have internal structs without marshalling them - nonamedreturns # we access errors in defer functions a lot - nosnakecase # deprecated, replaced by var-naming in revive, also doesn't work well with protobuf generated code - perfsprint # prefer readability over micro-performance optimizations - scopelint # deprecated, replaced by exportloopref - testpackage # interesting idea, but no need to overcomplicate testing - wsl # might be too much for enforcing styling fast: false issues: exclude: [] exclude-rules: # Exclude some linters from running on tests files. - path: main.go text: "deep-exit" - path: _mock\.go linters: - errcheck - forcetypeassert - gomnd - lll - wrapcheck - path: _test\.go linters: - containedctx - dupl - errcheck - exhaustive - funlen - lll - gocognit - goconst - gocyclo - goerr113 - gosec - varnamelen - path: \.resolvers\.go linters: - lll - path: shutdown.go text: "deep-exit" - path: _mock.go text: "argument-limit" - path: _test\.go text: "add-constant|cognitive-complexity|cyclomatic|function-length|line-length-limit|copylocks" exclude-use-default: false exclude-case-sensitive: false include: [] max-issues-per-linter: 0 max-same-issues: 0 new: false severity: default-severity: error case-sensitive: false ```

Go environment

```console $ go version && go env go version go1.22.2 darwin/arm64 GO111MODULE='on' GOARCH='arm64' GOBIN='' GOCACHE='/Users/me/Library/Caches/go-build' GOENV='/Users/me/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users/me/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='darwin' GOPATH='/Users/me/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/usr/local/go' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.22.2' GCCGO='gccgo' AR='ar' CC='clang' CXX='clang++' CGO_ENABLED='1' GOMOD='/Users/me/Projects/playground/go.mod' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/7y/hnr3l3td1pxg4y6gh_y70pmm0000gp/T/go-build114177719=/tmp/go-build -gno-record-gcc-switches -fno-common' ```

Verbose output of running

```console $ $ golangci-lint run -v I INFO [config_reader] Used config file ../golang-lint/v1.57.2/.golangci.yaml WARN [config_reader] The configuration option `run.skip-files` is deprecated, please use `issues.exclude-files`. WARN [config_reader] The configuration option `run.skip-dirs` is deprecated, please use `issues.exclude-dirs`. WARN [config_reader] The configuration option `output.format` is deprecated, please use `output.formats` WARN [config_reader] The configuration option `linters.govet.check-shadowing` is deprecated. Please enable `shadow` instead, if you are not using `enable-all`. WARN The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. WARN The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. WARN The linter 'ifshort' is deprecated (since v1.48.0) due to: The repository of the linter has been deprecated by the owner. WARN The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter. Replaced by unused. INFO [lintersdb] Active 92 linters: [asasalint asciicheck bidichk bodyclose containedctx contextcheck copyloopvar cyclop deadcode dogsled dupword durationcheck errcheck errchkjson errname errorlint execinquery exhaustive exportloopref forbidigo forcetypeassert funlen ginkgolinter gocheckcompilerdirectives gochecknoglobals gochecknoinits gochecksumtype gocognit goconst gocritic gocyclo godox goerr113 gofmt gofumpt goimports gomnd gomoddirectives goprintffuncname gosec gosimple gosmopolitan govet grouper ifshort inamedparam ineffassign intrange ireturn lll makezero mirror misspell nakedret nestif nilerr nilnil nlreturn noctx nolintlint nosprintfhostport paralleltest prealloc predeclared promlinter protogetter reassign revive rowserrcheck sloglint spancheck sqlclosecheck staticcheck structcheck stylecheck tagalign tagliatelle tenv testableexamples testifylint thelper tparallel unconvert unparam unused usestdlibvars varcheck varnamelen wastedassign whitespace wrapcheck zerologlint] INFO [loader] Go packages loading at mode 575 (imports|compiled_files|deps|exports_file|files|name|types_sizes) took 41.598208ms INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 104.792µs WARN [linters_context] deadcode: This linter is fully inactivated: it will not produce any reports. INFO [linters_context/goanalysis] analyzers took 395.417655ms with top 10 stages: gocritic: 323.8855ms, the_only_name: 53.006542ms, SA4003: 1.814625ms, buildir: 1.726836ms, unparam: 1.39825ms, gofumpt: 842.041µs, S1038: 576.708µs, forbidigo: 450.208µs, nilerr: 294.625µs, gofmt: 285.5µs ERRO [runner] Panic: intrange: package "main" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: ast.Expr is *ast.SelectorExpr, not *ast.Ident: goroutine 1294 [running]: runtime/debug.Stack() runtime/debug/stack.go:24 +0x64 github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe.func1() github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:108 +0x214 panic({0x101df9240?, 0x14001541380?}) runtime/panic.go:770 +0x124 github.com/ckaznocha/intrange.findNExpr({0x101f75608?, 0x140012db1c0?}) github.com/ckaznocha/intrange@v0.1.1/intrange.go:237 +0x1a0 github.com/ckaznocha/intrange.run.check.func1({0x101f71450?, 0x140012db200}) github.com/ckaznocha/intrange@v0.1.1/intrange.go:95 +0x1c4 golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0x14001cef650, {0x14002b64478?, 0x1027dbd40?, 0x1029918c0?}, 0x140029cfc68) golang.org/x/tools@v0.19.0/go/ast/inspector/inspector.go:82 +0x90 github.com/ckaznocha/intrange.run(0x1400155cc30) github.com/ckaznocha/intrange@v0.1.1/intrange.go:47 +0x124 github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyze(0x140028d6d50) github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:190 +0x8c4 github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe.func2() github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:112 +0x20 github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0x140021c7630, {0x1019e58d5, 0x8}, 0x14002b64730) github.com/golangci/golangci-lint/pkg/timeutils/stopwatch.go:111 +0x44 github.com/golangci/golangci-lint/pkg/goanalysis.(*action).analyzeSafe(0x100000000?) github.com/golangci/golangci-lint/pkg/goanalysis/runner_action.go:111 +0x78 github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze.func2(0x140028d6d50) github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go:80 +0xb0 created by github.com/golangci/golangci-lint/pkg/goanalysis.(*loadingPackage).analyze in goroutine 631 github.com/golangci/golangci-lint/pkg/goanalysis/runner_loadingpackage.go:75 +0x184 WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: intrange: package "main" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: ast.Expr is *ast.SelectorExpr, not *ast.Ident WARN [linters_context] ifshort: This linter is fully inactivated: it will not produce any reports. WARN [linters_context] structcheck: This linter is fully inactivated: it will not produce any reports. WARN [linters_context] varcheck: This linter is fully inactivated: it will not produce any reports. INFO [runner] processing took 1.164µs with stages: max_same_issues: 334ns, cgo: 167ns, skip_dirs: 125ns, path_prettifier: 42ns, identifier_marker: 42ns, skip_files: 42ns, autogenerated_exclude: 42ns, diff: 42ns, source_code: 41ns, max_from_linter: 41ns, filename_unadjuster: 41ns, path_shortener: 41ns, sort_results: 41ns, path_prefixer: 41ns, exclude: 41ns, nolint: 41ns, severity-rules: 0s, max_per_file_from_linter: 0s, fixer: 0s, invalid_issue: 0s, exclude-rules: 0s, uniq_by_line: 0s INFO [runner] linters took 518.427959ms with stages: goanalysis_metalinter: 518.232833ms, deadcode: 8.417µs, ifshort: 2.792µs, structcheck: 1.875µs, varcheck: 1.666µs ERRO Running error: can't run linter goanalysis_metalinter goanalysis_metalinter: intrange: package "main" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: ast.Expr is *ast.SelectorExpr, not *ast.Ident INFO Memory: 7 samples, avg is 80.6MB, max is 121.1MB INFO Execution took 565.023833ms ```

A minimal reproducible example or link to a public repository

```go package main import ( "reflect" ) func main() { err := foo("") if err != nil { return } } func foo(data any) error { v := reflect.ValueOf(data) for i := 0; i < v.Elem().NumField(); i++ { } return nil } ```

Validation

boring-cyborg[bot] commented 3 months ago

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

ldez commented 3 months ago

Hello,

The problem is already fixed by v1.58.

You should update golangci-lint.

TariqRWW commented 3 months ago

Thanks, upgrading to 1.58.0 resolved the issue