-
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
cmd/go: add a flag to set (or exclude) release tags #52078
Comments
I've been thinking about this some more, but I'm not sure that I really grokked the problem space. If the user has a (I don't see how users can realistically target an older Go version that they don't even have installed, given that the packages and identifiers in the Go standard library also change from one release to the next — are we planning to have |
Yes, that's part of the plan (see #50825) - add an analyzer to allow developers to preserve compatibility with older go versions independent of their installed version. For example, we frequently have this problem while working on gopls, that one doesn't discover that one has used a disallowed API until after mailing the CL and getting a build failure. Presumably this would also be useful for working on the compiler, which has a bootstrap requirement. But maybe we can insist that if users want the extra accuracy of building packages exactly as go 1.N, they must use go 1.N for I trust your intuition if you think this feature request is a bad idea. In light of the preceding paragraph I'm inclined to agree. Please feel free to close this based on your judgement. |
What if the user builds gopls with an older toolchain (say 1.17) then later updates the go on the PATH to 1.18? Ideally the tool should be able to process files that don't use 1.18 features, and should instruct the go command to select files according to go1.17 release tags. But it may fail to process a tree that depends on go1.18 features, just as a compiler would. That requires a way for the application to tell the go command to behave "no newer than" its own go version. |
Change https://go.dev/cl/435356 mentions this issue: |
An application that links in version 1.18 of (say) go/types cannot process Go source files reported by version 1.19 of 'go list'. There is no way to tell go list to behave as if it was go1.18, so for now we proceed with parsing/typechecking but, in case of errors, we issue an additional informative diagnostic. Fixes golang/go#55883 Fixes golang/go#55045 Updates golang/go#50825 Updates golang/go#52078 Change-Id: I5fd99b09742c136f4db7f71d2a75e4cdb730460d Reviewed-on: https://go-review.googlesource.com/c/tools/+/435356 gopls-CI: kokoro <[email protected]> Reviewed-by: Robert Findley <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Alan Donovan <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Auto-Submit: Alan Donovan <[email protected]> Reviewed-by: Zvonimir Pavlinovic <[email protected]>
In #50825, we want to allow developers to build gopls with a recent version of Go while still developing for older versions of Go. One blocker to doing this properly is that the set of release tags used in
go list
is not configurable: they are implied by the version of cmd/go.We had speculated that #42504 (ignore all build constraints) could help here, but the amount of post-processing required by gopls in that case is prohibitive.
Can we add a flag to cmd/go that allows us to mutate the set of release tags? For example, could we:
-release
flag (-release=1.16
)?-compat
flag (-compat=1.16
)?-notags
flag (-notags=go1.17,go1.18
)?I defer entirely to the cmd/go team for flag design, but it would be great to have some way to achieve this.
CC @bcmills @matloob
The text was updated successfully, but these errors were encountered: