golangci / golangci-lint

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

Running error: can't run linter goanalysis_metalinter with go.temporal.io/sdk #4425

Closed evgeniy-krivenko closed 9 months ago

evgeniy-krivenko commented 9 months ago

Welcome

Description of the problem

I've included the Temporal SDK package in my project and am now encountering the following error: "Running error: 1 error occurred: * can't run linter goanalysis_metalinter: inspect: failed to load package activity: could not load export data: no export data for "go.temporal.io/sdk/activity".

This error occurs when running locally, within a Docker container, and on a CI machine when installing the binary file. The error persists with both golangci-lint versions 1.54.1 and 1.56.2.

I've come across similar questions regarding this error and have attempted several solutions, including:

  1. Running go mod tidy
  2. Executing go clean -modcache && go clean -cache
  3. Using golangci-lint cache clean
  4. Trying out version 1.20 and 1.21 in the go.mod file
  5. Creating a clean project with my package and the Temporal dependency, then running the linter both locally on my machine and within a Docker container — resulting in the same error.

Any guidance or suggestions for resolving this issue would be greatly appreciated

Version of golangci-lint

```console $ golangci-lint --version # Paste output here golangci-lint has version 1.56.2 built with go1.22.0 from 58a724a on 2024-02-15T12:52:06Z ```

Configuration

```console # paste configuration file or CLI flags here run: tests: true concurrency: 4 timeout: 5m issues-exit-code: 1 issues: max-same-issues: 0 exclude-rules: - linters: - forbidigo path: tools/.* linters-settings: gci: sections: - standard - default - prefix(fastronom) custom-order: true godox: keywords: - FIXME - TODO lll: line-length: 130 tagliatelle: case: rules: json: snake toml: snake revive: rules: - name: blank-imports disabled: true linters: disable-all: true enable: - asasalint - asciicheck - bidichk - durationcheck - errcheck - errchkjson - errname - execinquery - exhaustive - exportloopref - forbidigo - gci - goconst - gocritic - gocyclo - godot - godox - gofmt - goheader - goimports - gomoddirectives - gomodguard - goprintffuncname - gosec - gosimple - govet - importas - ineffassign - lll - makezero - misspell - musttag - nakedret - nestif - nilnil - nolintlint - nosprintfhostport - prealloc - predeclared - promlinter - reassign - revive - staticcheck - stylecheck - tagliatelle - tenv - testableexamples - testpackage - thelper - typecheck - unconvert - unused - usestdlibvars - whitespace ```

Go environment

```console $ go version && go env # paste output here go version go1.21.7 darwin/arm64 GO111MODULE='on' GOARCH='arm64' GOBIN='' GOCACHE='/Users/ekrivenko/Library/Caches/go-build' GOENV='/Users/ekrivenko/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users/ekrivenko/go/pkg/mod' GONOPROXY='gitlab.a2seven.com/company-projects/bcs-life/go-packages/*' GONOSUMDB='gitlab.a2seven.com/company-projects/bcs-life/go-packages/*' GOOS='darwin' GOPATH='/Users/ekrivenko/go' GOPRIVATE='gitlab.a2seven.com/company-projects/bcs-life/go-packages/*' GOPROXY='https://proxy.golang.org,direct' GOROOT='/Users/ekrivenko/go/go1.21.7' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/Users/ekrivenko/go/go1.21.7/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.21.7' GCCGO='gccgo' AR='ar' CC='clang' CXX='clang++' CGO_ENABLED='1' GOMOD='/Users/ekrivenko/personal-repos/testlint/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/ym/z6r1ptw13ng67yfzlz4vxrgw0000gn/T/go-build1071379599=/tmp/go-build -gno-record-gcc-switches -fno-common' ```

Verbose output of running

```console $ golangci-lint cache clean $ golangci-lint run -v # paste output here INFO [config_reader] Config search paths: [./ /Users/ekrivenko/personal-repos/testlint /Users/ekrivenko/personal-repos /Users/ekrivenko /Users /] INFO [config_reader] Used config file .golangci.yml INFO [lintersdb] Active 53 linters: [asasalint asciicheck bidichk durationcheck errcheck errchkjson errname execinquery exhaustive exportloopref forbidigo gci goconst gocritic gocyclo godot godox gofmt goheader goimports gomoddirectives gomodguard goprintffuncname gosec gosimple govet importas ineffassign lll makezero misspell musttag nakedret nestif nilnil nolintlint nosprintfhostport prealloc predeclared promlinter reassign revive staticcheck stylecheck tagliatelle tenv testableexamples testpackage thelper unconvert unused usestdlibvars whitespace] INFO [loader] Go packages loading at mode 575 (deps|imports|types_sizes|compiled_files|exports_file|files|name) took 689.966ms INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 658.583µs INFO [linters_context] importas settings found, but no aliases listed. List aliases under alias: key. INFO [linters_context/goanalysis] analyzers took 9.326566176s with top 10 stages: buildir: 6.526665296s, exhaustive: 667.922951ms, inspect: 441.374999ms, fact_deprecated: 424.761624ms, ctrlflow: 366.15359ms, printf: 264.676017ms, fact_purity: 213.043374ms, typedness: 147.352464ms, nilness: 144.194122ms, SA5012: 122.584623ms WARN [runner] Can't run linter goanalysis_metalinter: inspect: failed to load package activity: could not load export data: no export data for "go.temporal.io/sdk/activity" INFO [runner] processing took 1.543µs with stages: max_same_issues: 292ns, nolint: 250ns, skip_dirs: 250ns, cgo: 167ns, path_prettifier: 125ns, filename_unadjuster: 125ns, fixer: 42ns, path_prefixer: 42ns, exclude: 42ns, skip_files: 42ns, path_shortener: 42ns, sort_results: 42ns, max_from_linter: 41ns, uniq_by_line: 41ns, severity-rules: 0s, exclude-rules: 0s, source_code: 0s, max_per_file_from_linter: 0s, diff: 0s, autogenerated_exclude: 0s, identifier_marker: 0s INFO [runner] linters took 3.705194583s with stages: goanalysis_metalinter: 3.705162125s ERRO Running error: can't run linter goanalysis_metalinter inspect: failed to load package activity: could not load export data: no export data for "go.temporal.io/sdk/activity" INFO Memory: 46 samples, avg is 306.3MB, max is 519.1MB INFO Execution took 4.4088375s ```

A minimal reproducible example or link to a public repository

https://github.com/evgeniy-krivenko/testlint

Validation

boring-cyborg[bot] commented 9 months ago

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

Antonboom commented 9 months ago

Hi, mate. Could you please do not ignore

A minimal reproducible example or link to a public repository

And push your example from point 5

evgeniy-krivenko commented 9 months ago

Updated issue, new project with example from point 5

Antonboom commented 9 months ago

@evgeniy-krivenko thanks

looks like some issue with go.temporal.io 🤔

I cloned sdk and did the next:

$ go version                                       
go version go1.22.0 darwin/arm64

$ golangci-lint version  
golangci-lint has version 1.56.2 built with go1.22.0 from 58a724a0 on 2024-02-15T18:01:51Z

$ golangci-lint run ./...
WARN [runner] Can't run linter goanalysis_metalinter: inspect: failed to load package activity: could not load export data: no export data for "go.temporal.io/sdk/activity" 
ERRO Running error: can't run linter goanalysis_metalinter
inspect: failed to load package activity: could not load export data: no export data for "go.temporal.io/sdk/activity" 

$ go mod edit -replace=go.temporal.io/sdk=../sdk-go
$ go mod tidy

$ golangci-lint run cache clean

$ golangci-lint run ./...      
go.mod:11:1: local replacement are not allowed: go.temporal.io/sdk (gomoddirectives)
replace go.temporal.io/sdk => ../sdk-go
^
internal/phonevalidator/service.go:12: File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(fastronom) --custom-order (gci)

internal/phonevalidator/service.go:25:2: field `defaultRequestTimeout` is unused (unused)
        defaultRequestTimeout time.Duration `default:"5s"`
evgeniy-krivenko commented 9 months ago

could not load export data

thanks, yep, it's go.temporal.io problem with grpc version deps. If set v1.26.0-rc.1 for temporal sdk, lint is okey!