-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/tools/go/packages: add module information to the Package struct #35921
Comments
This would probably make #35563 much simpler to implement. |
/cc @matloob @ianthehat |
For now the x/tools/go/packages package is meant to be build-system agnostic. Since modules don't appear in all Go build systems, that means that if we're keeping to being build-system agnostic. That might not be the right decision, but I think we should revisit that decision before deciding on this. Issue #38234 is somewhat relevant to this by the way. |
Being build-system agnostic shouldn't mean ignoring core Go features, though. |
I'm merging this issue with #38446. The main differences are that we still need to discuss exactly what struct we're putting in Package (module public is unexported, and whichever struct we pick should probably be defined in x/mod), and that we'd need a Need bit for the field. |
Here's the Module struct from
Is that what we want in go/packages? Is there anything we don't want in go/packages? |
SGTM. Will go/packages acquire Versions and Update? If not, we may want to skip those. |
Good point. Those could potentially be passed through as build flags, but that doesn't sound like something we'd want to encourage. |
It does sound like we should leave out Versions and Update, making the struct we're talking about adding:
I'm not sure about ModuleError either, but we can see how it goes. It sounds like people agree with the idea of adding the info. We can fine-tune the exact fields separately but the above is a start. Based on the discussion above, this sounds like a likely accept. |
No change in consensus, so accepted. |
Change https://golang.org/cl/234219 mentions this issue: |
Currently,
packages.Load
returns apackages.Package
object that contains useful information from thego list
API. However, sometimes the module information for the requested package is needed as well.My proposal is basically to add the
modinfo.ModulePublic
info fromgo list
to this package.Similar to
go list
, if the package is not part of a module or it's provided by theOverlay
API,Package.Module
will be nil.Let me know what do you think about this and I'll submit my CL for the proposal.
The text was updated successfully, but these errors were encountered: