-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: awkward "list -json" error reporting for a vendor
subdirectory that does not contain a Go package
#58418
Comments
The The removal of the |
Yes, understood that the target here is not a package, but it looks like the handling changed in a way that appears incorrect -- so this is a more scoped case of "behavior when calling The output in Go 1.19 correctly stated In contrast, the error output in 1.20 of |
We shouldn't even be spending the I/O operations to read the directory if we don't expect to find a package there (although we may mistakenly be doing so today). If we haven't read (or shouldn't have read) the directory, then we also shouldn't claim anything about whether that directory contains Go source files. So I don't think the |
vendor
subdirectory that does not contain a Go package
Thank you for the context -- in conjunction with looking at the change that introduced the behavior, I understand the mechanics better now. The behavior difference is due to the Both before and after the change, the following is executed for the vendor directory (so I/O is happening):
Prior to the change, the I'll leave this issue open since I do think there are still things that could be improved about the current output, but also understand that the behavior that I was consuming was an incidental one that happened to work but was not technically correct behavior, so will find a workaround for that on my end. Thank you. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run the following to create a module that vendors its dependencies and then run
go list -e -json
:What did you expect to see?
The JSON struct information for the requested module should contain the
Dir
field that indicates the directory for the module (the path should be in the vendor directory).What did you see instead?
The JSON struct printed as part of the output does not have a
Dir
field:This is the output of the command in the same directory using Go 1.19:
For context, the code I wrote that depends on this is doing the following:
The output of
go list
through Go 1.19 allowed this to be done, but the behavior change in Go 1.20 breaks this workflow, and I'm unsure why the output changed in this case.The error
"cannot query module due to -mod=vendor\n\t(Go version in go.mod is at least 1.14 and vendor directory exists.)"
is also misleading, since if the query is changed to be a package (golang.org/x/tools/go/packages
), thelist
operation succeeds and prints the package information (even though the same condition of "Go version in go.mod is at least 1.14 and vendor directory exists." is still true).The text was updated successfully, but these errors were encountered: