Skip to content

cmd/go: introduce subcommand to upgrade/downgrade import paths according to semantic import versioning #27248

Closed
@marwan-at-work

Description

@marwan-at-work

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 and go 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions