-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: "loadPackageData called with empty package path" build panic #60686
Comments
@bcmills I fear this is another one for you to look at. |
https://go-review.git.corp.google.com/c/go/+/424855 removed the check that (among other things) the import path was not empty. Before that, the file would have a parse error returned, go/build would move it to InvalidGoFiles, and the loader would ignore it. Now it's treated as a valid go file, we try to load the import and panic because the path is empty. I'll try to get a fix on monday. |
Change https://go.dev/cl/502615 mentions this issue: |
Change https://go.dev/cl/502697 mentions this issue: |
Change https://go.dev/cl/502697 mentions this issue: |
The go parser previously checked for invalid import paths, go/build, seeing the parse error would put files with invalid import paths into InvalidGoFiles. golang.org/cl/424855 removed that check from the parser, which meant files with invalid import paths not have any parse errors on them and not be put into InvalidGoFiles. Do a check for invalid import paths in go/build soon after parsing so we can make sure files with invalid import paths go into InvalidGoFiles. This fixes an issue where the Go command assumed that if a file wasn't invalid it had non empty import paths, leading to a panic. Fixes #60754 Updates #60230 Updates #60686 Change-Id: I33c1dc9304649536834939cef7c689940236ee20 Reviewed-on: https://go-review.googlesource.com/c/go/+/502615 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> (cherry picked from commit 962753b) Reviewed-on: https://go-review.googlesource.com/c/go/+/502697
What version of Go are you using (
go version
)?What did you do?
go build
What did you expect to see?
go 1.19
prog.go:3:8: invalid import path: ""
What did you see instead?
The text was updated successfully, but these errors were encountered: