Skip to content

gofmt ignoring skip-dirs on windows with GOOS specific files (cgo) #1392

Closed
@corylanou

Description

@corylanou

Thank you for creating the issue!

  • 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).

It appears that the gofmt linter (and goimports as it uses gofmt) does some type of pre-process, that results in the package that was told to be skipped is still processed.

Here are the files in the internal/cursor directory:

$ tree internal/cursor/
internal/cursor/
|-- cursor.go
|-- cursor_darwin.c
|-- cursor_darwin.go
|-- cursor_darwin.h
|-- cursor_windows.c
|-- cursor_windows.go
`-- cursor_windows.h

0 directories, 7 files

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version v1.31.0 built from (unknown, mod sum: "h1:+m9I3LEmxXLpymkXRPkDQGzOVBmBYm16UtDiXqZxWek=") on (unknown)
Config file
$ cat .golangci.yml
# This file contains all available configuration options
# with their default values.

run:
  skip-dirs-use-default: true
  skip-dirs:
    - internal/cursor
    - electron
    - docs
    - resources
    - windowsinstaller
    - scripts

linters:
  # please, do not use `enable-all`: it's deprecated and will be removed soon.
  # inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
  disable-all: true
  enable:
    #- asciicheck
    #- bodyclose
    #- deadcode
    #- errcheck
    - goimports
    #- golint
    #- gomnd
    #- gosec
    #- gosimple
    #- govet
    #- ineffassign
    #- interfacer
    #- nakedret
    #- nolintlint
    #- rowserrcheck
    #- scopelint
    #- staticcheck
    #- structcheck
    #- typecheck
    #- unconvert
    #- unparam
    #- unused
    #- varcheck
Go environment
$ go version && go env
go version go1.15 windows/amd64
set GO111MODULE=
set GOARCH=amd64
set GOBIN=c:\Users\cory\go\bin
set GOCACHE=C:\Users\cory\AppData\Local\go-build
set GOENV=C:\Users\cory\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\cory\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\cory\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\cory\projects\oliveai\bitbucket\sidekick\go.mod
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\cory\AppData\Local\Temp\go-build879693530=/tmp/go-build -gno-record-gcc-switches
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ C:\\Users\\cory\\projects\\oliveai\\bitbucket\\sidekick C:\\Users\\cory\\projects\\oliveai\\bitbucket C:\\Users\\cory\\projects\\oliveai C:\\Users\\cory\\projects C:\\Users\\cory C:\\Users C:\\]"
level=info msg="[config_reader] Used config file .golangci.yml"
level=info msg="[lintersdb] Active 1 linters: [goimports]"
level=info msg="[loader] Go packages loading at mode 7 (compiled_files|name|files) took 1.6537451s"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 2.1695167s"
level=info msg="[linters context/goanalysis] analyzers took 8.8913139s with top 10 stages: goimports: 8.8913139s"
level=info msg="[runner] Issues before processing: 8, after processing: 1"
level=info msg="[runner] Processors filtering stat (out/in): exclude-rules: 1/1, uniq_by_line: 1/1, diff: 1/1, path_prefixer: 1/1, skip_dirs: 8/8, autogenerated_exclude: 1/8, max_same_issues: 1/1, source_code: 1/1, path_shortener: 1/1, path_prettifier: 8/8, skip_files: 8/8, max_per_file_from_linter: 1/1, max_from_linter: 1/1, sort_results: 1/1, cgo: 8/8, filename_unadjuster: 8/8, nolint: 1/1, severity-rules: 1/1, identifier_marker: 1/1, exclude: 1/1"
level=info msg="[runner] processing took 1.9951ms with stages: path_prettifier: 997.7µs, autogenerated_exclude: 997.4µs, source_code: 0s, exclude-rules: 0s, uniq_by_line: 0s, max_per_file_from_linter: 0s, max_from_linter: 0s, severity-rules: 0s, sort_results: 0s, skip_files: 0s, filename_unadjuster: 0s, identifier_marker: 0s, nolint: 0s, path_shortener: 0s, cgo: 0s, path_prefixer: 0s, skip_dirs: 0s, exclude: 0s, diff: 0s, max_same_issues: 0s"
level=info msg="[runner] linters took 12.0365889s with stages: goimports: 12.0114871s"
..\..\..\..\AppData\Local\go-build\c8\c8ee6b174dd3bea5d4fa1cd2a9fd0c8fbe0a6a4b80eb9214ba36d397d83c5111-d:1: File is not `goimports`-ed (goimports)
package cursor
level=info msg="File cache stats: 1 entries of total size 3.5KiB"
level=info msg="Memory: 161 samples, avg is 1217.6MB, max is 2359.7MB"
level=info msg="Execution took 15.9439608s"

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cgoRelated to CGO or line directivesbugSomething isn't workingplatform: windowsIssue that is related to Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions