cmd/vet: go vet reporting error in vendor with cgo disabled #33569
Labels
Analysis
Issues related to static analysis (vet, x/tools/go/analysis)
GoCommand
cmd/go
modules
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
I have tried it with the golang:1.13-rc docker image, and it does reproduce. Same with the golang:1.12.5-stretch docker image.
What operating system and processor architecture are you using (
go env
)?go env
OutputIn addition, I have
GO111MODULE=on
What did you do?
I have a monorepo with many packages. Most are libraries, but a few are applications. My intention is to vet the code, test the code, and build the code via a shell script, and as quickly as possible. In this respect, I am running
go vet ./...
rather than checking each individual package.I have cgo disabled so that for our Linux builds, we can create static binaries for easy dockerization. The builds are happy.
There is one application which directly imports the Neo4J go packages, and these require cgo. When I build that one application, I enable cgo, and it's also happy.
Circling back to
go vet
, if I run with cgo enabled, it's happy. If I run with cgo disabled, I get errors (see below). I understand why those errors occur; the structs are defined in files that import "C", and with cgo disabled, they are unavailable. Cool. But it is my understanding that as of some versions ago, go tools (lint
, etc.) were supposed to ignore thevendor
directory.What did you expect to see?
No problems from
go vet
, as the troublesome package is in vendor.What did you see instead?
Etc.
I have a hypothesis.
go vet
isn't the tool which is unhappy with the Neo4J libraries. But maybego vet
has to compile my code, so that it can do its analysis? And if cgo is disabled, it can't do so.If that's the case, is there some way that I can work around this and still use
./...
togo vet
? If I build first and vet later, will vet discover the built packages (and if so, how does that work if I build to a non-standard location)?The text was updated successfully, but these errors were encountered: