go version)?$ go version go version go1.12.1 darwin/amd64
Yes
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"
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.
Cover to succeed without an internet connection
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)
...
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.
See also https://github.com/golang/go/issues/27841#issuecomment-433126152.
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
Most helpful comment
Picking up the vendor folder by default could also remove the need to pass the flag through. See #27227