cmd/cover: -coverpkg causes init methods to be run for non-imported packages #46212
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Very similar to #21283, but I think the distinction here is that if you run:
or
you get
init
calls from the qux package happening in thefoo
test suite, whenqux
is not imported. Withoutcoverpkg
this package does not get imported.I have made a repro with more information in the README here: https://github.com/benmoss/go-coverpkg-inits
What did you expect to see?
The qux package init function should only be run during tests that import it.
What did you see instead?
It is executed even when it is not imported.
The text was updated successfully, but these errors were encountered: