-
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: go/build: export functionality for finding and quering go.mod information #34173
Comments
Thank you for this proposal @oakad and welcome to the Go project! I have updated the issue title accordingly and the proposal review committee shall take a look at it in the coming days/weeks and others shall chime in as they gather inputs. |
The (accepted) proposal for exposing mod file capabilities in a package was #31761 go/build is deprecated in favor of go/packages, so we are very unlikely to add anything for modules to it, even if we were going to expose this in a package. |
Using Instead of simply invoking few friendly API calls and catching any major stdlib changes in compile time, one has to operate This all constitutes "unstable hackery", as referenced in my issue submission. :-) In fact, that whole process is lame enough as to warrant the |
Using cmd/go as an API means that we can provide a stable API surface that will work across multiple Go versions. There is no reasonable way to do that if code to parse the go.mod file is linked into the binary. That means that an old binary is unlikely to be able to read new go.mod files. But the cmd/go API can easily remain the same. In general the golang.org/x/tools/go/packages package is intended to provide a stable progammatic API, one that invokes cmd/go behind the scenes for you. It is likely that go/packages will move into the standard library when its API is considered stable. Closing because there is no plan to provide this information in go/build. |
I just want to note that I never asked for |
When designing build automation tools a common list of queries usually arises:
All this information can be obtained relatively easily with a bit of (unstable) hackery.
However, it will be substantially more convenient if all this information was simply available from go standard library, which has all the useful tools implemented in
internal/modload
package and friends.In particular,
build.Context
feels just like the right place to expose the above functionality to interested users.The text was updated successfully, but these errors were encountered: