xxpxxxxp / intellij-plugin-golangci-lint

GolangCI-Lint integration for IDEA
GNU General Public License v3.0
219 stars 15 forks source link

Go linter running error #121

Closed sig-saraf closed 2 years ago

sig-saraf commented 2 years ago

I'm facing error while running the Go Linter tool downloaded as a plugin from the market place, in my IntelliJ IDEA IDE. The following are the details around the scenario for your reference.

  1. Platform: MacOS 11.6
  2. IDE: IntelliJ IDEA 2021.2.1
  3. Go Linter: 1.5.10
  4. Go version: 1.17.6. $GOROOT is set in IDE under Preferences -> Languages & Frameworks -> Go -> GOROOT
  5. $GOPATH is also set in IDE globally under Preferences -> Languages & Frameworks -> Go -> GOPATH. I have set this for my projects that doesn't use go modules
  6. Enable Go modules integration is checked in my IDE under Preferences -> Languages & Frameworks -> Go -> Go Modules
  7. The Project Root is checked and set to the project directory under Preferences -> Tools -> Go Linter
  8. I'm not using any go linter config
  9. The go linter is working fine for project that is not using the go modules.
  10. I'm seeing error for project that is using go modules. I'm seeing the following error in the IDE pop up: Go linter running error Please make sure no syntax or config error, then run 'go mod tidy' to make sure deps ok
  11. The error from the IDE logs idea.log say: 2022-08-19 15:25:19,930 [ 270022] WARN - go-linter - Run error: level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for \"sig-gitlab.internal.organisation.com/name1/module1/path1\"" level=error msg="Running error: 1 error occurred:\n\t* can't run linter goanalysis_metalinter: buildir: failed to load package : could not load export data: no export data for \"sig-gitlab.internal.organisation.com/name1/module1/path1\"\n\n" . Please make sure the project has no syntax error. 2022-08-19 15:25:19,930 [ 270022] WARN - go-linter - Debug command: cd /Users/saraf/GoLang/name1/name2/project-dir && export PATH=/usr/local/go/bin:/usr/bin:/bin:/usr/sbin:/sbin && export GOPATH=/Users/saraf/OneDrive - Organisation, Inc/Documents/Projects/GoLang/Organisation:/Users/saraf/GoLang && '/usr/local/bin/golangci-lint' 'run' '--out-format' 'json' '--allow-parallel-runners' '-j' '4' '--issues-exit-code' '1' '--max-issues-per-linter' '0' '--max-same-issues' '0' '--no-config' '--disable-all' '-E' 'exportloopref,funlen,errchkjson,gocritic,goconst,errcheck,gci,gocognit,ineffassign,deadcode,asasalint,revive,bidichk,prealloc,staticcheck,gochecknoglobals,govet,dupl,errorlint,errname,typecheck,gochecknoinits,bodyclose,varcheck,asciicheck,gosec,goerr113,unconvert,unused,godox,stylecheck,whitespace,goprintffuncname,gosimple,godot,gocyclo' '.'
  12. Go linter work fine from the command line once I set GO111MODULE=auto
  13. The project that doesn't use the go modules is under $GOPATH but the project that uses the go modules is in a separate directory which is other than the $GOPATH

Any help would be really appreciating. Thanks in advance!

Version of golangci-lint

Information here is from Terminal

```console $ golangci-lint --version golangci-lint has version 1.48.0 built from 2d8fea81 on 2022-08-04T18:44:38Z Smart, fast linters runner. Run it in cloud for every GitHub pull request on https://golangci.com Usage: golangci-lint [flags] golangci-lint [command] Available Commands: cache Cache control and information completion Generate the autocompletion script for the specified shell config Config help Help linters List current linters configuration run Run the linters version Version Flags: --color string Use color when printing; can be 'always', 'auto', or 'never' (default "auto") -j, --concurrency int Concurrency (default NumCPU) (default 16) --cpu-profile-path string Path to CPU profile output file -h, --help help for golangci-lint --mem-profile-path string Path to memory profile output file --trace-path string Path to trace output file -v, --verbose verbose output --version Print version Use "golangci-lint [command] --help" for more information about a command. ```

Configuration file

Not using any configuration file

```console $ cat .golangci.yml # paste output here ```

Go environment

Information here is from Terminal

```console $ go version && go env go version go1.17.6 darwin/amd64 GO111MODULE="auto" GOARCH="amd64" GOBIN="" GOCACHE="/Users/saraf/Library/Caches/go-build" GOENV="/Users/saraf/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/saraf/OneDrive - Organisation, Inc/Documents/Projects/GoLang/Organisation/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/saraf/OneDrive - Organisation, Inc/Documents/Projects/GoLang/Organisation" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64" GOVCS="" GOVERSION="go1.17.6" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/saraf/GoLang/name1/name2/project-dir/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/vk/h5m5cfzn73q7www5534lnglh0000gn/T/go-build297741147=/tmp/go-build -gno-record-gcc-switches -fno-common" ```

Verbose output of running

Information here is from Terminal

```console $ golangci-lint cache clean $ golangci-lint run -v INFO [config_reader] Config search paths: [./ /Users/saraf/GoLang/name1/name2/project-dir /Users/saraf/GoLangname1/name2 /Users/saraf/GoLang/name1 /Users/saraf/GoLang /Users/saraf /Users /] INFO [lintersdb] Active 9 linters: [deadcode errcheck gosimple govet ineffassign staticcheck typecheck unused varcheck] INFO [loader] Go packages loading at mode 575 (compiled_files|deps|exports_file|files|imports|types_sizes|name) took 473.006996ms INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 2.686085ms INFO [linters context/goanalysis] analyzers took 5.96179916s with top 10 stages: buildir: 3.376326765s, printf: 349.71887ms, fact_deprecated: 348.604479ms, ctrlflow: 348.595946ms, fact_purity: 318.28135ms, SA5012: 313.080793ms, nilness: 311.984591ms, typedness: 287.962666ms, inspect: 181.443544ms, S1038: 9.256725ms INFO [runner] Issues before processing: 6, after processing: 4 INFO [runner] Processors filtering stat (out/in): cgo: 6/6, path_prettifier: 6/6, nolint: 4/4, diff: 4/4, max_per_file_from_linter: 4/4, max_from_linter: 4/4, source_code: 4/4, path_prefixer: 4/4, autogenerated_exclude: 6/6, identifier_marker: 6/6, exclude-rules: 4/6, uniq_by_line: 4/4, severity-rules: 4/4, filename_unadjuster: 6/6, skip_files: 6/6, skip_dirs: 6/6, path_shortener: 4/4, exclude: 6/6, max_same_issues: 4/4, sort_results: 4/4 INFO [runner] processing took 5.462356ms with stages: nolint: 2.862008ms, autogenerated_exclude: 960.566µs, source_code: 917.982µs, skip_files: 331.885µs, exclude-rules: 162.351µs, path_prettifier: 98.95µs, identifier_marker: 91.625µs, skip_dirs: 22.702µs, path_shortener: 3.004µs, uniq_by_line: 2.976µs, max_same_issues: 2.793µs, cgo: 1.57µs, max_from_linter: 1.374µs, filename_unadjuster: 813ns, max_per_file_from_linter: 654ns, sort_results: 290ns, diff: 276ns, severity-rules: 214ns, exclude: 203ns, path_prefixer: 120ns INFO [runner] linters took 2.480707568s with stages: goanalysis_metalinter: 2.475137302s main_test.go:916:18: Error return value of `io.WriteString` is not checked (errcheck) io.WriteString(w, content) ^ main_test.go:951:17: Error return value of `io.WriteString` is not checked (errcheck) io.WriteString(w, content) ^ main.go:279:4: ineffectual assignment to versionSupported (ineffassign) versionSupported = true ^ main.go:331:6: ineffectual assignment to versionSupported (ineffassign) versionSupported = true ^ INFO File cache stats: 2 entries of total size 45.4KiB INFO Memory: 31 samples, avg is 213.2MB, max is 339.4MB INFO Execution took 2.970343509s ```

Code example or link to a public repository

Non-public project

```go // add your code here ```
xxpxxxxp commented 2 years ago

Hi @sig-saraf , I've made an update, does the latest version working for you?

sig-saraf commented 2 years ago

@xxpxxxxp I'm seeing the latest version as 1.5.10 in my IntelliJ marketplace and the above scenario is using that. Any instructions how or where can I see and install the even latest?

xxpxxxxp commented 2 years ago

The latest version is 1.6.0, click Intellij IDEA on the left top, check for updates, it will update all plugins to latest version

sig-saraf commented 2 years ago

@xxpxxxxpI was on an older version of IntelliJ and your version 1.6.0 was not supported on that version of IDE. I updated my IDE and the plugin too, and I confirm it seems to be working for me now. Great, thanks! Feel free to close this.