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/go: coverpkg=all fails when dot imports . are present #23432

Closed
ghost opened this issue Jan 12, 2018 · 2 comments
Closed

cmd/go: coverpkg=all fails when dot imports . are present #23432

ghost opened this issue Jan 12, 2018 · 2 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@ghost
Copy link

ghost commented Jan 12, 2018

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

go1.10beta2

go version devel +594668a5a9 Thu Jan 11 17:44:08 2018 +0000 darwin/amd64

Does this issue reproduce with the latest release?

With go1.9.2 it works fine:

$ go test -coverpkg=all ./...
warning: no packages being tested depend on archive/tar
...
warning: no packages being tested depend on vendor/golang_org/x/text/unicode/norm
?   	demo	[no test files]

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

$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/myself/go/demo"
GORACE=""
GOROOT="/Users/myself/.gvm/gos/go1.9.2"
GOTOOLDIR="/Users/myself/.gvm/gos/go1.9.2/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/1_/931p_3ms15b07mhkkmmzz1qc0000gp/T/go-build361849763=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

Created main.go:

package main

import . "fmt"

func main() {
	Println("example")
}

Ran test with -coverpkg=all

$ go test -coverpkg=all ./...
# demo
./main.go:5: invalid array index 0 (out of bounds for 0-element array)
./main.go:9: GoCover_0 redeclared in this block
	previous declaration during import "fmt"

What did you expect to see?

Should have no errors, same as when -coverpkg=all is not specified:

$  go test  ./...
?   	demo	[no test files]

What did you see instead?

-coverpkg=all seems to be adding variables GoCover_0 to the current package as well as the . imported "fmt" package. That causes the current package to not compile because GoCover_0 is redeclared in this package.

@bradfitz bradfitz added NeedsFix The path to resolution is known, but the work has not been done. release-blocker labels Jan 12, 2018
@bradfitz bradfitz added this to the Go1.10 milestone Jan 12, 2018
@bradfitz
Copy link
Contributor

/cc @rsc

@ianlancetaylor ianlancetaylor changed the title go1.10beta2: coverpkg=all fails when dot imports . are present cmd/go: coverpkg=all fails when dot imports . are present Jan 12, 2018
@gopherbot
Copy link

Change https://golang.org/cl/89135 mentions this issue: cmd/go: fix -coverpkg=all with dot imports

@golang golang locked and limited conversation to collaborators Jan 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

2 participants