-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: "no go files in <dir>" error missing directory with list -json=<fields> if fields doesn't contain Dir #64946
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
Comments
Change https://go.dev/cl/553795 mentions this issue: |
is this the same as #26296 ? |
I think they're related, but I think this issue would show up even with the fix Alan suggested if -json didn't contain ImportPath because we would zero out the ImportPath field if it's not requested. |
go list -json=<fields> zeroes out the fields in the package struct that aren't specified. The problem with this is that some of the fields have references into other fields: specifically, the NoGoError's Error() function accesses the package struct's Dir field, so if we clear it out the error will just print out "no Go files in" without a directory. Instead, make a copy of the package struct before we zero out the fields so the original values are still there. For #64946 Change-Id: I95103e91fa0782bb23a86a965d5eb87cb12654c6 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/553795 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
go list -json=<fields> zeroes out the fields in the package struct that aren't specified. The problem with this is that some of the fields have references into other fields: specifically, the NoGoError's Error() function accesses the package struct's Dir field, so if we clear it out the error will just print out "no Go files in" without a directory. Instead, make a copy of the package struct before we zero out the fields so the original values are still there. For golang#64946 Change-Id: I95103e91fa0782bb23a86a965d5eb87cb12654c6 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/553795 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
This was fixed by golang.org/cl/553795 |
Go version
go version go1.21.4 darwin/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
In the following module
run
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: