cmd/go: mismatched line number and import path in error messages #72896
Labels
BugReport
Issues describing a possible bug in the Go implementation.
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes (this is the latest release at time of writing)
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I'm attempting to use go workspaces with
GOPROXY=off
to ensure I have all required sources locally. In the middle of this work, I have a single module and a workspace with the following local structure:go.work:
hello/go.mod:
hello/go.sum
hello/hello.go
Then I run
GOPROXY="off" go build hello.go
from thehello
directory.What did you expect to see?
I expected error messages related to
golang.org/x/crypto
andgolang.org/x/net
being unavailable because they are not in the workspace and can't be found/downloaded because ofGOPROXY=off
.What did you see instead?
This is the error output:
The first line is correct, but the second line in the error output (
hello.go:7:2: golang.org/x/crypto@v0.36.0: module lookup disabled by GOPROXY=off
), refers to line7
on the source, which is the"golang.org/x/net/html/charset"
import on the file listed above. The surprising behavior is that the import is forgolang.org/x/net
but the error message says it's forgolang.org/x/crypto
.Additionally, when I run the command with JSON output (
GOPROXY="off" go build -json hello.go
) I get the same messages in the "Output" keys but the right paths in "ImportPath":Finally, if I disable "workspace mode" by renaming the go.work file I get error messages that don't say explicitly which import failed, but at least don't give the wrong path:
The text was updated successfully, but these errors were encountered: