-
Notifications
You must be signed in to change notification settings - Fork 18.9k
cmd/go: list reports same PackageError.Pos for each import of a given missing package #78183
Copy link
Copy link
Open
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.FixPendingIssues that have a fix which has not yet been reviewed or submitted.Issues that have a fix which has not yet been reviewed or submitted.GoCommandcmd/gocmd/go
Milestone
Description
The following test case demonstrates a bug in the way go list reports errors for missing dependencies. (This may be the root cause of the downstream issue #73933 in gopls.)
$ cat cmd/go/testdata/script/golist-missingimport.txt
# This script demonstrates a bug(?) in go list's reporting of dependency errors:
# The location of the first import that encounters the error is used
# for all other imports. This confuses downstream tools, including go/packages and gopls.
env GOWORK=off
go list -e -f '{{range .DepsErrors}}package {{$.ImportPath}}: error at {{.Pos}}: {{.Err}}{{end}}' ./...
# The second assertion (in package q) fails; instead it reports p.go a second time.
stdout 'package example.com/test/p: error at p/p.go:3:8: no required module...'
stdout 'package example.com/test/q: error at q/q.go:3:8: no required module...'
-- go.mod --
module example.com/test
go 1.22
-- p/p.go --
package p
import _ "example.com/missing"
-- q/q.go --
package q
import _ "example.com/missing"$ go test ./cmd/go -v -run=TestScript/golist-missingimport
script_test.go:162: FAIL: testdata/script/golist-missingimport.txt:11: stdout 'package example.com/test/q: error at q/q.go:3:8: no required module...': no match for `(?m)package example.com/test/q: error at q/q.go:3:8: no required module...` in stdout
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.FixPendingIssues that have a fix which has not yet been reviewed or submitted.Issues that have a fix which has not yet been reviewed or submitted.GoCommandcmd/gocmd/go