How to increment the major version of a go module using GoLand

Let’s look at the workflow of incrementing the major version of a module using the module definition taken from our What’s New in GoLand repository:

module renameab.le/module

go 1.11

Upgrading a module means bumping the version tag in version control. We also need to change our import paths. For example, if to bump the module version from `v1` to `v2`, we need our imports changed from:




Obviously, this can appear in lots of places in the code. Good news: the IDE can do this for you.

With the 2021.1 version of GoLand, you can use the Rename refactoring to complete this workflow. To do this, place the cursor on the module’s name in the go.mod file, in our example renameab.le/module, and invoke the Rename refactoring via Shift+F6. (You can also invoke the Rename refactoring using the Refactor This feature via Ctrl+Alt+Shift+T on Windows/Linux or Ctrl+T on macOS.)

Pro tip: This will also update all references to the current module name across all the Go files, test or not. Click on the Preview button to see where the change will take place.

Sometimes, as soon as you click Refactor, you change your mind. “Oh no, now I have to find all those imports, file name changes, etc., and put them back.” Good news: the IDE can undo that entire editor transaction, including file changes and VCS operations.

Another reason to use this operation: as with any IDE refactoring, the Local History can save you. Here’s how the Rename operation looks like in the Local History.


Our IDEs are great at automating routine work. Here we saw how we could use the Rename refactoring to make sure that we can safely and efficiently rename our modules when incrementing their major version. The Rename refactoring can also change the name of identifiers, files, and folders. GoLand contains other refactoring features too, and you can find out more about them in this series of articles.

Please let us know your feedback in the comments section below, on our issue tracker, in the #goland channel of Gophers Slack, or via our social media such as Twitter @GoLandIDE.

Discover more