Go: cmd/cover: accept -mod=vendor as an explicit flag

Created on 25 Mar 2019  路  6Comments  路  Source: golang/go

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

$ go version
go version go1.12.1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/lipscoda/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/lipscoda/workspace/code"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/lipscoda/workspace/code_archive/docker.appspace.api/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 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/m0/5_69c64x3110wqw6mv5kr934h0n8s5/T/go-build218403268=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I am using modules with a vendor folder, when i try to run go tool cover it attempts to connect to the internet to download the dependencies.

What did you expect to see?

Cover to succeed without an internet connection

What did you see instead?

cover: cannot run go list: exit status 1
go: gopkg.in/src-d/[email protected]: unrecognized import path "gopkg.in/src-d/go-git.v4" (https fetch: Get https://gopkg.in/src-d/go-git.v4?go-get=1: dial tcp: lookup gopkg.in on 192.168.65.1:53: no such host)
go: k8s.io/[email protected]+incompatible: unrecognized import path "k8s.io/client-go" (https fetch: Get https://k8s.io/client-go?go-get=1: dial tcp: lookup k8s.io on 192.168.65.1:53: no such host)
...
NeedsInvestigation

Most helpful comment

Picking up the vendor folder by default could also remove the need to pass the flag through. See #27227

All 6 comments

What was the exact command you ran? (Your go env output shows an empty GOFLAGS, so how were you passing -mod=vendor to go tool cover?)

Fwiw we had the same issue, and really we just weren't aware that the go tool cover invocation will use flags from GOFLAGS envvar, and expected an explicit -mod flag for the tool. Maybe something to clarify in -help?

Because go tool cover was calling go list without any arguments I was getting that error, being new to go I wasn't aware of the GOFLAGS env var could set global flags. I'm ok using GOFLAGS now but maybe you could consider adding the -mod flag to go tool since it calls other tools that may require it.

Change https://golang.org/cl/170863 mentions this issue: cmd/gopherbot: CC triaged issues to owners

Picking up the vendor folder by default could also remove the need to pass the flag through. See #27227

Was this page helpful?
0 / 5 - 0 ratings