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 the vendor directory.
What did you expect to see?
No problems from go vet, as the troublesome package is in vendor.
I have a hypothesis. go vet isn't the tool which is unhappy with the Neo4J libraries. But maybe go 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 ./... to go 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)?