-
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
proposal: x/tools/go/packages: add Goroot to Packages struct #43499
Comments
Why not just rely on the rule described in #32819? It's technically not documented yet, but the rule already exists in practice and can be relied upon. Two of my tools use it already, and it's cheaper than having to query the packages. |
Thanks for highlighting the undocumented convention. It unfortunately doesn't catch the case where "a module name without a dot happens to build today" (quoted from your issue). Either way, it's cleaner to rely on a bool on a |
If you do absolutely need such low level details, I'd suggest to try just using |
I indeed reach in to So either the developer needs to find a workaround to x/tools/go/packages, or needs to bypass it while reaching into
I'm not sure what you mean by this: is it designed to support some specific build systems (which ones? Bazel? Any others?) or that it is designed to support third-party build systems in general? What details are "too specific" vs. not? Why would you want to shut down this proposal vs. the three resulting from your issue #38234? I am using x/tools/go/packages for a build tool that extracts certain resource files from a program's (recursive) import dependencies; for the purposes of this issue, skipping GoRoot packages because they never contain such files and thus avoids unnecessary directory scans that can improve build times. The same tool can benefit from #38445 which is why I commented there in November last year. |
Yes, Bazel is the main other one.
They are similar, and I'm not shutting down anything. I'm just saying that if you want a lot of the fields from |
Hi, I'm the maintainer of go/packages. We don't want to shut down the proposal, but go/packages was originally designed to be build system agnostic (as in supporting other build systems like Bazel). For now, it's much easier to use go list to get this information. This is partially why #38445 is still open |
Please export
Goroot
inPackage
. It is available ingo list -f '{{ .Goroot }}'
.The only way to programmatically get it right now is to use a workaround to get the package dir, then compare to
runtime.GOROOT()
.The text was updated successfully, but these errors were encountered: