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: modify the whole workspace with go get #61397

Open
goto1134 opened this issue Jul 17, 2023 · 3 comments
Open

proposal: cmd/go: modify the whole workspace with go get #61397

goto1134 opened this issue Jul 17, 2023 · 3 comments

Comments

@goto1134
Copy link

Consider the following scenario when the user has an intention to upgrade or downgrade a dependency in the workspace:

  1. Clone https://github.com/sergunya/my_workspace
  2. run go get github.com/rs/zerolog@latest or go get -u github.com/rs/zerolog or go get github.com/rs/zerolog@1.26.0 (the latter is for downgrade)
  3. the root go.mod is modified, and the module cmd/my_app/go.mod file is not modified.

As a result, for the upgrade action, the buildlist contains the latest version of the dependency, and the inner module lists an outdated dependency version.
For the downgrade action, since the inner module contains a higher version, the buildlist does not change, so the downgrade has no effect on the project.

Consider applying the go get command to the whole workspace.

  • If an upgrade happens, all the modules containing a dependency should be upgraded.
  • If a downgrade was called, all the modules that contain a dependency should be downgraded.

Additional scenario:

  1. Clone https://github.com/sergunya/my_workspace
  2. run go get github.com/rs/zerolog@latest
  3. cd cmd/my_app
  4. go mod tidy

As a result, cmd/my_app/go.mod does not change, but the github.com/rs/zerolog line does not align with the buildlist.

Consider changing the require directives if with the version from buildlist on go mod tidy.

@gopherbot gopherbot added this to the Proposal milestone Jul 17, 2023
@seankhliao
Copy link
Member

isn't this what go work sync does?

@goto1134
Copy link
Author

isn't this what go work sync does?

Indeed, it is a way to solve the problem with upgrades, but for the downgrades, unfortunately, it doesn't work, since it will replace the lower version with a higher one

@bcmills
Copy link
Contributor

bcmills commented Jul 17, 2023

This is a lot like #50750, in that there are really two modes you might be operating in:

  • If the workspace is a set of modules that are all under your control, you probably want to update them all at the same time.
  • On the other hand, if you are working on a patch to send to some upstream maintainer, you probably want to avoid unnecessary changes to their module.

For #50750, we have two separate commands (go work sync and go mod tidy respectively) intended for those two modes of use. But we don't currently have a workspace-scoped analogue for go get.

(CC @matloob)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Incoming
Development

No branches or pull requests

4 participants