You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does this issue reproduce with the latest release?
It doesn't reproduce with Go 1.20.x.
On the current main branch, it is shadowed by the issue described in #64520 (but I still opened this separate issue as I'm not sure whether fixing the other one would fix this one, and this one appears in a released version).
It also reproduces on different OS and architectures (eg. linux/amd64)
What operating system and processor architecture are you using (go env)?
The example declares a global variable which indirectly calls runtime.Caller, which returns covervars.go instead of the actual filename.
The bug is triggered by running go test ./... -cover, a test which checks that the filename contains package1 will fail.
If this is not considered a bug, the documentation should make it clear that runtime.Caller can return something else when called from a global variable when running in a test with coverage enabled.
What did you expect to see?
runtime.Caller should return <root>/mypackage1/myfile.go.
What did you see instead?
runtime.Caller returns covervars.go.
The text was updated successfully, but these errors were encountered: