Closed switchupcb closed 1 year ago
Hello,
you have a compilation issue, to diagnose:
golangci-lint
is built with a compatible version of Go.go mod tidy
.go run ./...
/go build ./...
- the whole package.FYI skip-dirs
just excludes the final reports but not the analysis if your code depends on this package.
$ docker run --rm -it golang:1.20-alpine sh
/go # apk add -q curl git
/go # curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.53.3
golangci/golangci-lint info checking GitHub for tag 'v1.53.3'
golangci/golangci-lint info found version: 1.53.3 for v1.53.3/linux/amd64
golangci/golangci-lint info installed /go/bin/golangci-lint
/go # git clone --quiet https://github.com/switchupcb/disgo.git
/go # cd disgo/_gen/
/go/disgo/_gen # go build ./...
pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies
/go/disgo/_gen # go build .
main module (github.com/switchupcb/disgo) does not contain package github.com/switchupcb/disgo/_gen
/go/disgo/_gen # go build ./...
pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies
/go/disgo/_gen # export GOWORK=off
/go/disgo/_gen # go build ./...
go: downloading golang.org/x/exp v0.0.0-20221114191408-850992195362
tools/copygen/events/setup.go:4:2: no required module provides package github.com/switchupcb/disgo/wrapper; to add it:
go get github.com/switchupcb/disgo/wrapper
tools/copygen/events/template/generate.go:10:2: no required module provides package github.com/switchupcb/copygen/cli/models; to add it:
go get github.com/switchupcb/copygen/cli/models
/go/disgo/_gen #
Everything works as expected, skip-dirs
just excludes the final reports but not the analysis, your code doesn't compile, so golangci-lint cannot perform the analysis.
Nevermind, you are attempting to build using go build ./...
while I built using ./
.
https://github.com/golangci/golangci-lint/issues/3939#issuecomment-1620830161
Note: it's LDEZ not IDEZ
How do I exclude the files from the build?
I suppose the real solution is to move the code outside of the generator.
You can use build tags.
Another solution is also to rename the folder to start with _
so it gets excluded from the build. So I renamed copygen
to _copygen
and it worked.
Thanks for the help!
Welcome
Description of the problem
I can't run the command
golangci-lint run ./...
in this folder from./_gen
withGOWORK=off
. This operation should lint all.go
files (except those specified byskip-dirs
in this configuration file.Error
\"github.com/switchupcb/disgo/wrapper\"
is only imported by thecopygen
folder (specified inskip-dirs
).Otherwise, the package is being loaded from outside the directory even though it isn't referenced by any of the packages that are linted.
Version of golangci-lint
Configuration file
Go environment
Verbose output of running
Code example or link to a public repository