Skip to content

Linter doesn't work on Windows #2488

@inliquid

Description

@inliquid

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. (https://golangci-lint.run/usage/linters/)

Description of the problem

I'm using VS Code and run linters from there. In one of the projects golangci-lint doesn't work on Windows. Exact same setup on Linux runs fine. One of the possible causes is that there some cgo indirect dependency on github.com/DataDog/zstd.

Here is the output:
изображение

As I said, exact same thing runs on Linux with no issues.

I also tried running another linters, such as revive, and they also work well. Problem is only with golangci-lint on Windows.

Tried both with and without gcc toolchain in %PATH%.

Version of golangci-lint

Details
>golangci-lint --version
golangci-lint has version 1.43.0 built from 861262b7 on 2021-11-03T11:57:46Z

Configuration file

Details
default config

Go environment

Details
>go version
go version go1.17.6 windows/amd64

>go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\***\AppData\Local\go-build
set GOENV=C:\Users\***\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\***\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\***\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17.6
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\***\AppData\Local\Temp\go-build896296837=/tmp/go-build -gno-record-gcc-switches

Verbose output of running

Details
>golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ C:\\Users\\***\\go\\src\\***\\***\\***\\*** C:\\Users\\***\\go\\src\\***\\***\\*** C:\\Users\\***\\go\\src\\***\\*** C:\\Users\\***\\go\\src\\*** C:\\Users\\***\\go\\src C:\\Users\\***\\go C:\\Users\\*** C:\\Users C:\\]"
level=info msg="[lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]"
level=info msg="[loader] Go packages loading at mode 575 (deps|files|imports|name|types_sizes|compiled_files|exports_file) took 4.0645084s"

...

level=error msg="[linters context] typechecking error: C:\\Program Files\\Go\\src\\runtime\\cgo\\cgo.go:34:8: could not import C (cgo preprocessing failed)"
level=info msg="[linters context/goanalysis] analyzers took 2m50.0817829s with top 10 stages: buildir: 44.7348026s, nilness: 13.6262614s, printf: 12.2132039s, ctrlflow: 11.3239871s, fact_purity: 11.1788192s, typedness: 11.0942s, fact_deprecated: 11.0152296s, SA5012: 10.4196803s, inspect: 3.071394s, directives: 1.7010036s"
level=warning msg="[runner] Can't run linter goanalysis_metalinter: buildir: failed to load package zstd: could not load export data: no export data for \"github.com/DataDog/zstd\""
level=info msg="[runner] processing took 0s with stages: severity-rules: 0s, autogenerated_exclude: 0s, exclude: 0s, max_same_issues: 0s, path_shortener: 0s, path_prefixer: 0s, sort_results: 0s, cgo: 0s, skip_dirs: 0s, exclude-rules: 0s, nolint: 0s, path_prettifier: 0s, source_code: 0s, diff: 0s, max_per_file_from_linter: 0s, max_from_linter: 0s, filename_unadjuster: 0s, skip_files: 0s, identifier_marker: 0s, uniq_by_line: 0s"
level=info msg="[runner] linters took 15.7436282s with stages: goanalysis_metalinter: 15.7436282s"
level=info msg="File cache stats: 0 entries of total size 0B"
level=info msg="Memory: 197 samples, avg is 648.6MB, max is 1699.1MB"
level=info msg="Execution took 19.9701484s"

Code example or link to a public repository

Details

n/a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions