In the module’s go.mod file, revise the module path to append the new major version number, as in the following example:

example.com/mymodule/v2
In the module’s go.mod file, revise the module path to append the new major version number, as in the following example:

example.com/mymodule/v2
When making a pre-release available, keep in mind that developers using the pre-release will need to explicitly specify it by version with the go get command. That’s because, by default, the go command prefers release versions over pre-release versions when locating the module you’re asking for. So developers must get the pre-release by specifying it explicitly, as in the following example:

go get example.com/theirmodule@v1.2.3-alpha
Here’s an example of a stable version number:

v1.0.0
Here are two examples:

v0.2.1-beta.1
v1.2.3-alpha
Since both private and public Go modules are source repositories, publishing a private Go module follows the same process as publishing a public one. To publish your new module, stage your changes in the current directory using the git add command, then commit those changes to your local repository with the git commit command:

git add .
git commit -m "Initial private module implementation"
Using your module’s Cobra dependency as an example, suppose you need to reference commit 07445ea of github.com/spf13/cobra because it has some changes you need and you can’t use another version for some reason. In this case, you can provide the commit hash after the @ symbol the same as you would for a branch or a tag. Run the go get command in your mymodule directory with the module and version to download the new version:

go get github.com/spf13/cobra@07445ea
To publish a new version of your own module using these tags, you will tag the code you’re releasing with the git tag command. As an argument to the git tag command, you’ll also need to provide the version tag. To create the version tag, start with the prefix v, for version, and add your SemVer immediately after it. In the case of your module, your final verison tag would be v0.1.0. Now, run git tag to tag your module with the version tag:

git tag v0.1.0
The output will look similar to this, showing that the only change in your module is the method you added to pubmodule.go:

OutputOn branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   pubmodule.go

no changes added to commit (use "git add" and/or "git commit -a")
Next, add the change to the staged files and commit the change to your local repository with git add and git commit:

git add .
git commit -m "Add Goodbye method"

Recommend

Go Module release and versioning workflow Publishing the first stable version

Go Module release and versioning workflow Publishing the first (unstable) version

Go Module release and versioning workflow Publishing pre-release versions

Go Contribution Guide Miscellaneous topics Sending multiple dependent changes

Go Contribution Guide Miscellaneous topics Set up git aliases

Go Contribution Guide Miscellaneous topics Reviewing code by others

Go Contribution Guide Miscellaneous topics Synchronize your client

Go Contribution Guide Miscellaneous topics Specifying a reviewer / CCing others

Go Contribution Guide Miscellaneous topics Quickly testing your changes

Go Contribution Guide Miscellaneous topics Troubleshooting mail errors

Go Contribution Guide Miscellaneous topics Copyright headers

Contribution Guide Good commit messages

Go Contribution Guide Sending a change via Gerrit Step 5: Revise changes after a review

Go Contribution Guide Sending a change via Gerrit Step 4: Send changes for review

Go Contribution Guide Sending a change via Gerrit Step 3: Test your changes In the golang.org/x/... repositories

Contribution Guide Sending a change via Gerrit Step 3: Test your changes In the main Go repository

Go Contribution Guide Sending a change via Gerrit Step 2: Prepare changes in a new branch

Go Contribution Guide Sending a change via Gerrit Step 1: Clone the source code

Go Contribution Guide Sending a change via Gerrit Overview

Go Contribution Guide Becoming a contributor Step 4: Install the git-codereview command

Contribution Guide Becoming a contributor Step 0: Select a Google Account

Go Contribution Guide Becoming a contributor Overview

Go Diagnostics Debugging

Go Diagnostics Profiling

How to Write Go Code Testing

How to Write Go Code Your first program Importing packages from remote modules

How to Write Go Code Your first program Importing packages from your module

How to Write Go Code Your first program

The Go Programming Language Specification System considerations Size and alignment guarantees

The Go Programming Language Specification System considerations Package unsafe

The Go Programming Language Specification Run-time panics

The Go Programming Language Specification Errors

The Go Programming Language Specification Program initialization and execution Program execution

The Go Programming Language Specification Program initialization and execution Package initialization

The Go Programming Language Specification Program initialization and execution The zero value

The Go Programming Language Specification Packages An example package

The Go Programming Language Specification Packages Import declarations

The Go Programming Language Specification Packages Package clause

The Go Programming Language Specification Packages Source file organization

The Go Programming Language Specification Built-in functions Bootstrapping

The Go Programming Language Specification Built-in functions Handling panics

The Go Programming Language Specification Built-in functions Manipulating complex numbers

The Go Programming Language Specification Built-in functions Deletion of map elements

The Go Programming Language Specification Built-in functions Appending to and copying slices

The Go Programming Language Specification Built-in functions Making slices, maps and channels