-
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: introduce subcommand to upgrade/downgrade import paths according to semantic import versioning #27248
Comments
It also doesn't seem specific to major versions: for example, one might want to perform conceptually the same operation to start a fork of a module with a new module path. That doesn't fit nicely into the I'm happy to see external tools to do this (perhaps in |
@bcmills makes sense. Maybe Lastly, my only semantic comment is that upgrading to a new version in my opinion is not a "fix". It's part of the regular flow of development. So I'd expect |
Nobody outside of your module should “need” to update their import paths when you publish a new major version: that's the whole point of semantic import paths. (If the different major versions need to share some sort of global state to avoid conflicts, you can do that by defining the old version to forward to the new, or by using a third So the only person who “needs” to upgrade import paths is you (the creator of the new module path), and you know about it already! For everyone else, updating to the new major version should be more of a “cleanup” than a “fix”, strictly speaking: it shouldn't change the behavior of the code, but does express the underlying structure more directly. |
@bcmills hah! True. But I was actually referring to package owners as opposed to packages users. Package owners should have an easy way to find out how to go about upgrading their own packages w/ go modules when they get to that point. For now, the Go Wiki maybe is enough? If so, happy to close this issue. Thanks! |
Let's start with the wiki. (Honestly, I think the wiki may be more discoverable than Thanks again for all the great tooling contributions, |
Would it make sense to re-open this for tracking purposes, perhaps re-labeled such that it is not specifically about cmd/go? In other words, it makes sense why this was closed initially, but maybe makes sense to re-purpose it a bit and keep as a tracking issue for a possible future @marwan-at-work, not to put you too much on the spot, but do you think your current implementation would lend itself to living in something like CC @jayconrod |
Slightly more context: While semantic import versioning has value, there is also some transition pain that flows from semantic import versioning, and the best answer to me seems to be better tooling to reduce that pain in a material way. https://github.com/marwan-at-work/mod is great for people who know about it and who are willing to trust it. However, I hope that type of functionality will eventually be in |
Summary
If you have a repository with a number of sub packages that import each other and you'd like to introduce a breaking change (tagging a new major version), then you have to manually update all import paths everywhere in that repository including the go.mod file.
I propose we introduce two new subcommands
go mod upgrade
andgo mod downgrade
that will do the above automatically.It would also be nice to include a flag to jump a few versions so that repositories already tagged with say v8.0.0 can run
go mod upgrade -t=v8
I've written a tool that does this as a reference: https://github.com/marwan-at-work/mod
And I've used it to open a few PRs for popular packages such as google/martian#262
What version of Go are you using (
go version
)?1.11
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Darwin
What did you do?
Wanted to update a Go repository to a new major version
What did you expect to see?
An automated tool that updates the go.mod file as well as all import paths.
What did you see instead?
Had to do it manually.
The text was updated successfully, but these errors were encountered: