Skip to content
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: cmd/go: allow go get to choose versions based on the go version constraints #59886

Closed
hyangah opened this issue Apr 28, 2023 · 3 comments
Labels
FeatureRequest GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Proposal
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Apr 28, 2023

With extended forwards compatibility feature (#57001), the go line in go.mod will prescribe the minimum go version required to compile the go module. If the work module says go 1.27 but a dependency says go 1.28, the work module should update its go.mod to require at least go 1.28.

https://go.googlesource.com/proposal/+/master/design/57001-gotoolchain.md#effect-in-dependencies

For library module maintainers who want to have better control of their minimum go version requirements, dependency update can be rather challenging. They have to pick the dependency version carefully to avoid bumping up their own modules' go version because one of their dependencies chose to bump their go version in their latest release.

We can think of various ways of helping users choose the right version such as

  • extend the go list -m --versions to present the minimum required go version for each version.
  • make pkgsite present the minimum required go version in its version view (which works only on open-source modules and not very convenient)

However, querying the requirement individually doesn't scale well when there are many dependencies.
It would be nice if the go get has an option to compute and choose the latest versions compatible with the given go version requirement.

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 28, 2023
@dmitshur dmitshur added this to the Backlog milestone Apr 28, 2023
@dmitshur
Copy link
Contributor

CC @matloob, @bcmills.

@ianlancetaylor ianlancetaylor modified the milestones: Backlog, Proposal May 10, 2023
@ianlancetaylor ianlancetaylor changed the title cmd/go: allow go get to choose versions based on the go version constraints proposal: cmd/go: allow go get to choose versions based on the go version constraints May 10, 2023
@rsc
Copy link
Contributor

rsc commented Jun 14, 2023

This already works as long as you know what Go version you want. You can do

go get dep1 dep2 dep3 go@1.21

and it will only consider dep1 dep2 dep3 versions that don't require Go newer than Go 1.21.

@rsc
Copy link
Contributor

rsc commented Jun 14, 2023

Closing as done.

@rsc rsc closed this as completed Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FeatureRequest GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Proposal
Projects
Status: Accepted
Development

No branches or pull requests

4 participants