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/cover: support -mod and other build flags #35869

Open
dtelyukh opened this issue Nov 27, 2019 · 2 comments
Open

cmd/cover: support -mod and other build flags #35869

dtelyukh opened this issue Nov 27, 2019 · 2 comments
Labels
Milestone

Comments

@dtelyukh
Copy link

@dtelyukh dtelyukh commented Nov 27, 2019

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

$ go version
go version go1.13.4 linux/amd64

Does this issue reproduce with the latest release?

Yes, it does

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dionysius/.cache/go-build"
GOENV="/home/dionysius/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/dionysius/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build322712138=/tmp/go-build -gno-record-gcc-switches"

What did you do?

GO_PATH/~/go/pkg/mod/ dir is empty

$go tool cover -html=../coverage.cov -o ../coverage.html

What did you expect to see?

After running the cover command GO_PATH/~/go/pkg/mod/ dir is still empty

What did you see instead?

After running the cover command GO_PATH/~/go/pkg/mod/ dir is not empty

@dmitshur

This comment has been minimized.

Copy link
Member

@dmitshur dmitshur commented Dec 2, 2019

/cc @jayconrod @bcmills This may be related to cmd/go or cmd/cover, but I'm not sure who owns the cover cool.

I don't see cmd/cover mentioned in #24661. We should add it there so it's easier to know whether it supports module mode.

@dmitshur dmitshur changed the title How to instructs the cover command to use the main module's top-level vendor directory to satisfy dependencies? It doesn't recognize -mod flag. cmd/go: how to get the cover command to use the main module's top-level vendor directory to satisfy dependencies; it doesn't recognize -mod flag Dec 2, 2019
@jayconrod jayconrod changed the title cmd/go: how to get the cover command to use the main module's top-level vendor directory to satisfy dependencies; it doesn't recognize -mod flag cmd/cover: support -mod and other build flags Dec 2, 2019
@jayconrod jayconrod added the NeedsFix label Dec 2, 2019
@jayconrod jayconrod added this to the Backlog milestone Dec 2, 2019
@jayconrod

This comment has been minimized.

Copy link
Contributor

@jayconrod jayconrod commented Dec 2, 2019

This is similar to #35200, but this is for cmd/cover instead of cmd/doc.

Both commands invoke the go list internally. Neither command provides a way to pass through build flags. We should at least support -mod.

@dtelyukh You can work around this in Go 1.13 by adding -mod=vendor to the GOFLAGS environment variable when invoking go tool cover. For example GOFLAGS=-mod=vendor go tool cover -html=../coverage.cov -o ../coverage.html.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.