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

cmd/vet: go vet reporting error in vendor with cgo disabled #33569

Open
provPaulBrousseau opened this issue Aug 9, 2019 · 1 comment
Open

cmd/vet: go vet reporting error in vendor with cgo disabled #33569

provPaulBrousseau opened this issue Aug 9, 2019 · 1 comment

Comments

@provPaulBrousseau
Copy link

@provPaulBrousseau provPaulBrousseau commented Aug 9, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.7 darwin/amd64

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 Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/paulbrousseau/Library/Caches/go-build"
GOEXE=""
GOFLAGS="-mod=vendor"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/paulbrousseau/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.7/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="0"
GOMOD="/Users/paulbrousseau/work/devex/go/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ys/3_9lwjwj3hj9nbry2j249x5h0000gq/T/go-build483197916=/tmp/go-build -gno-record-gcc-switches -fno-common"

In 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 the vendor directory.

What did you expect to see?

No problems from go vet, as the troublesome package is in vendor.

What did you see instead?

# github.com/neo4j-drivers/gobolt
vendor/github.com/neo4j-drivers/gobolt/connector_worker.go:30:14: undefined: Config
vendor/github.com/neo4j-drivers/gobolt/connector_worker.go:31:15: undefined: seaboltConnector

Etc.

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)?

@bcmills bcmills changed the title go vet reporting error in vendor with cgo disabled cmd/go: go vet reporting error in vendor with cgo disabled Aug 9, 2019
@bcmills bcmills added this to the Go1.14 milestone Aug 9, 2019
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Aug 9, 2019

CC @mvdan @ianthehat for cmd/vet.

CC @jayconrod for cmd/go.

@bcmills bcmills added the modules label Aug 9, 2019
@bcmills bcmills changed the title cmd/go: go vet reporting error in vendor with cgo disabled cmd/vet: go vet reporting error in vendor with cgo disabled Sep 17, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.