Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: Duplicate symbols with more than one main package in -coverpkg #34114
What version of Go are you using (
We're also seeing this on go1.13 linux/amd64, though I can't get it to reproduce outside our build machine.
Deleting .cache/go-build had no effect, other than to change the error output to this -- I haven't been able to find who sets $WORK, but there are no _pkg_.a or _go_.o files on disk:
I'm seeing the same problem here (no problem with Go <= 1.12.x).
After the comment from @maxatome I made some tests on our private project.
Didn't try replicating this behavior on an example repo, might try doing so in the following days if time permits.
I've managed to create a very small repo that reproduces the issue: https://github.com/emiguens/go-cover-fail.
After cloning the repo just run
$ go test ./... -coverprofile=coverage.out -coverpkg=./... -count=1 ? github.com/emiguens/go-cover-fail [no test files] # github.com/emiguens/go-cover-fail/pkg1.test 2019/09/10 19:27:09 duplicate symbol main.main (types 1 and 1) in main and /Users/emiguens/Library/Caches/go-build/24/24691ab861edac4f0767346c8d02eb886ed269874dacb9e5f27dc53368bb053c-d(_go_.o) FAIL github.com/emiguens/go-cover-fail/pkg1 [build failed] # github.com/emiguens/go-cover-fail/pkg2.test 2019/09/10 19:27:09 duplicate symbol main.main (types 1 and 1) in main and /Users/emiguens/Library/Caches/go-build/24/24691ab861edac4f0767346c8d02eb886ed269874dacb9e5f27dc53368bb053c-d(_go_.o) FAIL github.com/emiguens/go-cover-fail/pkg2 [build failed] FAIL
If I remove the
All in all it seems to be something related with using a
Hope this helps =D
I've further reduced the test case, now it fails without having any external dependencies (only using the standard library). Just a main package with a subpackage with one function, so no vendor directory either.
Just in case, you can see the commit history in the linked project to see how the test case evolved.