Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
corylanou opened this issue Sep 22, 2020 · 3 comments · Fixed by #3025
Closed
3 tasks done

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

corylanou opened this issue Sep 22, 2020 · 3 comments · Fixed by #3025
Labels
area: cgo Related to CGO bug Something isn't working platform: windows Issue that is related to Windows

Comments

@corylanou
Copy link

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"
@corylanou corylanou added the bug Something isn't working label Sep 22, 2020
@boring-cyborg
Copy link

boring-cyborg bot commented Sep 22, 2020

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

@corylanou
Copy link
Author

I forgot to mention that if you run only gofmt you get the same error result. That should probably be the use case for reproducing and not goimports as I'm sure it's the gofmt plugin that actually creates the error.

@ldez ldez added the platform: windows Issue that is related to Windows label Feb 21, 2021
@stale
Copy link

stale bot commented Mar 30, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale No recent correspondence or work activity label Mar 30, 2022
@ldez ldez changed the title gofmt ignoring skip-dirs on windows with GOOS specific files gofmt ignoring skip-dirs on windows with GOOS specific files (cgo) Mar 30, 2022
@stale stale bot removed the stale No recent correspondence or work activity label Mar 30, 2022
@ldez ldez added the area: cgo Related to CGO label May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cgo Related to CGO bug Something isn't working platform: windows Issue that is related to Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants