Skip to content

erro: 'can't run linter goanalysis_metalinter: buildssa': failed to load package cmd: could not load export data: no export data for "..." #3546

Closed
@acgreek

Description

@acgreek

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc.).
  • Yes, I've tried with the standalone linter if available (e.g., gocritic, go vet, etc.). (https://golangci-lint.run/usage/linters/)

Description of the problem

I have found similar issues reported, though they are all 'closed' and reading through them I didn't find a solution that worked for me. I was able to find that I could make the issue go-away by disabling the following golangci-lint plugin: govet, megacheck, revive stylecheck, contextcheck, exhaustive

So this is also a feature request that when a plugin fails, it should say which plugin failed. This would save a user like myself from have to disable plugins in blocks until I find all the plugins that don't work. Also the error message is not very useful in saying what is wrong

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version 1.50.1 built from 8926a95f on 2022-10-22T10:50:47Z

Configuration file

This is the not working .golangci.yaml:

$ cat .golangci.yml
# This file contains all available configuration options
# with their default values.

# options for analysis running
run:

  # timeout for analysis, e.g. 30s, 5m, default is 1m
  deadline: 3m

  # include test files or not, default is true
  tests: false


  # which dirs to skip: they won't be analyzed;
  # can use regexp here: generated.*, regexp is applied on full path;
  # default value is empty list, but next dirs are always skipped independently
  # from this option's value:
  #     vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
  skip-dirs:
    - pkg/api
    - vendor/

  # which files to skip: they will be analyzed, but issues from them
  # won't be reported. Default value is empty list, but there is
  # no need to include all autogenerated files, we confidently recognize
  # autogenerated files. If it's not please let us know.
  skip-files:
    - ".*\\.my\\.go$"
    - lib/bad.go

  # by default isn't set. 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.
  #modules-download-mode: readonly|release|vendor


# output configuration options
output:
  # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
  format: colored-line-number

  # print lines of code with issue, default is true
  print-issued-lines: true

  # print linter name in the end of issue text, default is true
  print-linter-name: true


# all available settings of specific linters
linters-settings:
  errcheck:
    # report about not checking of errors in type assetions: `a := b.(MyStruct)`;
    # default is false: such cases aren't reported by default.
    check-type-assertions: false

    # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
    # default is false: such cases aren't reported by default.
    check-blank: false

    # [deprecated] comma-separated list of pairs of the form pkg:regex
    # the regex is used to ignore names within pkg. (default "fmt:.*").
    # see https://github.com/kisielk/errcheck#the-deprecated-method for details
    ignore: fmt:.*,io/ioutil:^Read.*

    # path to a file containing a list of functions to exclude from checking
    # see https://github.com/kisielk/errcheck#excluding-functions for details
    # exclude: /path/to/file.txt
  funlen:
    lines: 150
    statements: 75
  govet:
    # report about shadowed variables
    check-shadowing: false
  golint:
    # minimal confidence for issues, default is 0.8
    min-confidence: 0.8
  gofmt:
    # simplify code: gofmt with `-s` option, true by default
    simplify: true
  goimports:
  # put imports beginning with prefix after 3rd-party packages;
  # it's a comma-separated list of prefixes
  #local-prefixes: github.com/org/project
  gocyclo:
    # minimal code complexity to report, 30 by default (but we recommend 10-20)
    min-complexity: 25
  maligned:
    # print struct with more effective memory layout or not, false by default
    suggest-new: true
  dupl:
    # tokens count to trigger issue, 150 by default
    threshold: 100
  goconst:
    # minimal length of string constant, 3 by default
    min-len: 3
    # minimal occurrences count to trigger, 3 by default
    min-occurrences: 3
  depguard:
    list-type: blacklist
    include-go-root: false
    packages:
      - github.com/davecgh/go-spew/spew
  misspell:
    # Correct spellings using locale preferences for US or UK.
    # Default is to use a neutral variety of English.
    # Setting locale to US will correct the British spelling of 'colour' to 'color'.
    locale: US
    ignore-words:
      - someword
      - mitre
  lll:
    # max line length, lines longer will be reported. Default is 120.
    # '\t' is counted as 1 character by default, and can be changed with the tab-width option
    line-length: 140
    # tab width in spaces. Default to 1.
    tab-width: 1
  unused:
    # treat code as a program (not a library) and report unused exported identifiers; default is false.
    # XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
    # if it's called for subdir of a project it can't find funcs usages. All text editor integrations
    # with golangci-lint call it on a directory with the changed file.
    check-exported: false
  unparam:
    # Inspect exported functions, default is false. 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.
    check-exported: false
  nakedret:
    # make an issue if func has more lines of code than this setting and it has naked returns; default is 30
    max-func-lines: 30
  prealloc:
    # XXX: we don't recommend using this linter before doing performance profiling.
    # For most programs usage of prealloc will be a premature optimization.

    # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
    # True by default.
    simple: true
    range-loops: true # Report preallocation suggestions on range loops, true by default
    for-loops: false # Report preallocation suggestions on for loops, false by default
  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:
    # - rangeValCopy

    # Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
    disabled-checks:
      - regexpMust
      - ifElseChain  # subject to annoying FPs due to naive static analysis

    # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks.
    # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
    enabled-tags:
      - performance

    settings: # settings passed to gocritic
      captLocal: # must be valid enabled check name
        paramsOnly: true
      rangeValCopy:
        sizeThreshold: 32

linters:
  enable:
    - containedctx
    - decorder
    - depguard
    - dogsled
    - dupl
    # - dupword // not in u
    - errcheck
    - errname
    - execinquery
    # - exhaustruct
    - exportloopref
    - funlen
    - gochecknoglobals
    - gochecknoinits
    - gocognit
    - goconst
    - gocritic
    - gocyclo
    - godot
    - godox
    - goerr113
    - gofmt
    - goimports
    - gomnd
    - gomodguard
    - goprintffuncname
    - gosec
    - govet
    - lll
    - megacheck
    - misspell
    - nakedret
    - nestif
    - nolintlint
    - prealloc
    - revive
    - stylecheck
    - testpackage
    - unconvert
    - unused
    - unparam
    - whitespace
  disable:
    - wsl
    - scopelint
    - varcheck
    - structcheck
    - deadcode
    - typecheck
  presets:
    - bugs
    - unused
  fast: false

And this is the working .golangci.yaml:

# This file contains all available configuration options
# with their default values.

# options for analysis running
run:

  # timeout for analysis, e.g. 30s, 5m, default is 1m
  deadline: 3m

  # include test files or not, default is true
  tests: false


  # which dirs to skip: they won't be analyzed;
  # can use regexp here: generated.*, regexp is applied on full path;
  # default value is empty list, but next dirs are always skipped independently
  # from this option's value:
  #     vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
  skip-dirs:
    - pkg/api
    - vendor/

  # which files to skip: they will be analyzed, but issues from them
  # won't be reported. Default value is empty list, but there is
  # no need to include all autogenerated files, we confidently recognize
  # autogenerated files. If it's not please let us know.
  skip-files:
    - ".*\\.my\\.go$"
    - lib/bad.go

  # by default isn't set. 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.
  #modules-download-mode: readonly|release|vendor


# output configuration options
output:
  # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
  format: colored-line-number

  # print lines of code with issue, default is true
  print-issued-lines: true

  # print linter name in the end of issue text, default is true
  print-linter-name: true


# all available settings of specific linters
linters-settings:
  errcheck:
    # report about not checking of errors in type assetions: `a := b.(MyStruct)`;
    # default is false: such cases aren't reported by default.
    check-type-assertions: false

    # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
    # default is false: such cases aren't reported by default.
    check-blank: false

    # [deprecated] comma-separated list of pairs of the form pkg:regex
    # the regex is used to ignore names within pkg. (default "fmt:.*").
    # see https://github.com/kisielk/errcheck#the-deprecated-method for details
    ignore: fmt:.*,io/ioutil:^Read.*

    # path to a file containing a list of functions to exclude from checking
    # see https://github.com/kisielk/errcheck#excluding-functions for details
    # exclude: /path/to/file.txt
  funlen:
    lines: 150
    statements: 75
  govet:
    # report about shadowed variables
    check-shadowing: false
  golint:
    # minimal confidence for issues, default is 0.8
    min-confidence: 0.8
  gofmt:
    # simplify code: gofmt with `-s` option, true by default
    simplify: true
  goimports:
  # put imports beginning with prefix after 3rd-party packages;
  # it's a comma-separated list of prefixes
  #local-prefixes: github.com/org/project
  gocyclo:
    # minimal code complexity to report, 30 by default (but we recommend 10-20)
    min-complexity: 25
  maligned:
    # print struct with more effective memory layout or not, false by default
    suggest-new: true
  dupl:
    # tokens count to trigger issue, 150 by default
    threshold: 100
  goconst:
    # minimal length of string constant, 3 by default
    min-len: 3
    # minimal occurrences count to trigger, 3 by default
    min-occurrences: 3
  depguard:
    list-type: blacklist
    include-go-root: false
    packages:
      - github.com/davecgh/go-spew/spew
  misspell:
    # Correct spellings using locale preferences for US or UK.
    # Default is to use a neutral variety of English.
    # Setting locale to US will correct the British spelling of 'colour' to 'color'.
    locale: US
    ignore-words:
      - someword
      - mitre
  lll:
    # max line length, lines longer will be reported. Default is 120.
    # '\t' is counted as 1 character by default, and can be changed with the tab-width option
    line-length: 140
    # tab width in spaces. Default to 1.
    tab-width: 1
  unused:
    # treat code as a program (not a library) and report unused exported identifiers; default is false.
    # XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
    # if it's called for subdir of a project it can't find funcs usages. All text editor integrations
    # with golangci-lint call it on a directory with the changed file.
    check-exported: false
  unparam:
    # Inspect exported functions, default is false. 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.
    check-exported: false
  nakedret:
    # make an issue if func has more lines of code than this setting and it has naked returns; default is 30
    max-func-lines: 30
  prealloc:
    # XXX: we don't recommend using this linter before doing performance profiling.
    # For most programs usage of prealloc will be a premature optimization.

    # Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
    # True by default.
    simple: true
    range-loops: true # Report preallocation suggestions on range loops, true by default
    for-loops: false # Report preallocation suggestions on for loops, false by default
  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:
    # - rangeValCopy

    # Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
    disabled-checks:
      - regexpMust
      - ifElseChain  # subject to annoying FPs due to naive static analysis

    # Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint` run to see all tags and checks.
    # Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
    enabled-tags:
      - performance

    settings: # settings passed to gocritic
      captLocal: # must be valid enabled check name
        paramsOnly: true
      rangeValCopy:
        sizeThreshold: 32

linters:
  enable:
    - containedctx
    - decorder
    - depguard
    - dogsled
    - dupl
    # - dupword // not in u
    - errcheck
    - errname
    - execinquery
    # - exhaustruct
    - exportloopref
    - funlen
    - gochecknoglobals
    - gochecknoinits
    - gocognit
    - goconst
    - gocritic
    - gocyclo
    - godot
    - godox
    - goerr113
    - gofmt
    - goimports
    - gomnd
    - gomodguard
    - goprintffuncname
    - gosec
    - lll
    - misspell
    - nakedret
    - nestif
    - nolintlint
    - prealloc
    - testpackage
    - unconvert
    - unused
    - unparam
    - whitespace
  disable:
    - govet
    - megacheck
    - revive
    - stylecheck
    - wsl
    - scopelint
    - varcheck
    - structcheck
    - deadcode
    - typecheck
    - contextcheck
    - exhaustive
  presets:
    - bugs
    - unused
  fast: false

Go environment

$ go version && go env
go version go1.18.10 linux/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS="-buildvcs=false"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB="removed.io/*,removed.io/*"
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://removed/"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.10"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/code/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3385784503=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /code / /root] 
INFO [config_reader] Used config file .golangci.yaml 
INFO [lintersdb] Active 58 linters: [asasalint asciicheck bidichk bodyclose containedctx contextcheck decorder depguard dogsled dupl durationcheck errcheck errchkjson errname errorlint execinquery exhaustive exportloopref funlen gochecknoglobals gochecknoinits gocognit goconst gocritic gocyclo godot godox goerr113 gofmt goimports gomnd gomodguard goprintffuncname gosec gosimple govet ineffassign lll loggercheck makezero misspell nakedret nestif nilerr noctx nolintlint prealloc reassign revive rowserrcheck sqlclosecheck staticcheck stylecheck testpackage unconvert unparam unused whitespace] 
INFO [lintersdb] Active presets: [bugs unused]    
INFO [loader] Go packages loading at mode 575 (imports|types_sizes|compiled_files|deps|files|exports_file|name) took 10.425033s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 77.176ms 
INFO [linters_context/goanalysis] analyzers took 1m21.284369s with top 10 stages: buildir: 33.892112s, buildssa: 28.023601s, gocritic: 3.005592s, exhaustive: 2.4384s, inspect: 2.335095s, ctrlflow: 1.881358s, fact_deprecated: 1.825049s, printf: 1.522754s, nilness: 1.177379s, fact_purity: 1.160215s 
WARN [runner] Can't run linter goanalysis_metalinter: buildssa: failed to load package connectionstate: could not load export data: no export data for "code.8labs.io/apps/data-ingest/taegis/endpoints/endpoint-sdk/service/connectionstate" 
WARN [linters_context] rowserrcheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649. 
WARN [linters_context] sqlclosecheck is disabled because of generics. You can track the evolution of the generics support by following the https://github.com/golangci/golangci-lint/issues/2649. 
INFO [runner] processing took 756µs with stages: diff: 229µs, path_shortener: 144µs, sort_results: 114µs, uniq_by_line: 35µs, filename_unadjuster: 33µs, max_same_issues: 26µs, max_per_file_from_linter: 24µs, exclude-rules: 22µs, max_from_linter: 14µs, path_prefixer: 14µs, autogenerated_exclude: 12µs, nolint: 12µs, source_code: 11µs, severity-rules: 10µs, skip_files: 10µs, cgo: 10µs, skip_dirs: 10µs, path_prettifier: 9µs, identifier_marker: 9µs, exclude: 8µs 
INFO [runner] linters took 18.805333s with stages: goanalysis_metalinter: 18.800893s, rowserrcheck: 468µs, sqlclosecheck: 122µs 
ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: buildssa: failed to load package removed: could not load export data: no export data for "remove/path"
 
INFO Memory: 291 samples, avg is 310.3MB, max is 686.5MB 
INFO Execution took 29.327421s   

Code example or link to a public repository

// add your code here

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfeedback requiredRequires additional feedback

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions