Closed micahcoffman closed 5 years ago
Looking through the code for golangci-lint I see that some linters won't run on packages that don't compile. But I would fully expect vet to run and output errors.
I see, the error i'm looking for is actually covered by typecheck, so i'm guessing govet is excluding the errors that typecheck would output by default.
This can be closed if someone verifies that's how it is supposed to work.
I'm seeing similar behavior. Consider:
~/go/src/istio.io/istio/mixer/pkg/attribute$ golangci-lint run --no-config --disable-all --enable=govet
~/go/src/istio.io/istio/mixer/pkg/attribute$ golangci-lint run --no-config --disable-all --enable=typecheck
~/go/src/istio.io/istio/mixer/pkg/attribute$ go vet ./...
# istio.io/istio/mixer/pkg/attribute
./protoBag.go:80: Scope.Debugf format %s reads arg #2, but call has 1 arg
so the golangci-lint version of vet and typecheck don't find the extra %s present in the format string, but 'go vet' does.
I'm not sure about that issue with typecheck you are seeing, but it looks like golangci-lint won't run govet on packages that don't compile which doesn't make sense to me. The runner for govet gets a list of packages from lintCtx.Program.InitialPackages()
https://github.com/golangci/golangci-lint/blob/v1.15.0/pkg/golinters/govet.go#L52 which is populated in the loader, excluding packages that don't compile https://github.com/golangci/golangci-lint/blob/v1.15.0/pkg/lint/load.go#L91-L100.
This should be fixed in the newer runner for govet that was merged since it uses lintCtx.Packages
https://github.com/golangci/golangci-lint/blob/master/pkg/golinters/goanalysis/linter.go#L118 which is populated with https://github.com/golangci/golangci-lint/blob/v1.15.0/pkg/lint/load.go#L321
@jirfag do you have an eta on when you'll tag a new release? it would be nice to get those newer govet changes out so I can switch to using just govet instead of counting on typecheck etc to run on packages that don't compile.
Note that in the case I posted above, the code is fully compiled. The warning is not detected by golangci-lint using either typecheck or vet, but is detected by plain go vet.
hi!
Can't find the repository github.com/expel-io/nightingale
to check. Also, can't reproduce in istio.io/istio/mixer.
The new release 1.16.0 already contains new govet. Can you check it, please?
Sure, i'll give it a go! FWIW the code is meant to be compiled for linux, and and setting the GOOS=linux
causes a different error. So the issue may be more related to cross compilation. I've seen an older issue that is related, but it got closed out.
compilation errors are reported by typecheck
When I run
go vet ./...
I see:When I run
golangci-lint run -v --no-config --disable-all --enable=govet
I see:I would expect golangci-lint to report the vet error, but it doesn't at all. This is preventing me from switching to golangci-lint from gometalinter.
golangci-lint --version
:go version
:go env
: