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
modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dtelyukh
Copy link

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 dmitshur added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Dec 2, 2019
@dmitshur
Copy link
Contributor

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 The path to resolution is known, but the work has not been done. label Dec 2, 2019
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 2, 2019
@jayconrod jayconrod added this to the Backlog milestone Dec 2, 2019
@jayconrod
Copy link
Contributor

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
Labels
modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants