Upgrade your Go project to next major version [Part-II]

Seamlessly Upgrade your project with these steps

Arbaaz Khan
2 min readMay 29, 2023

If you want to release this major version with the module version upgrade in Github and are curious to know how to one can use the updated go modules then just follow along with me:

6) Release your project

Releasing process doesn’t change, it’s the same as any other repository in Github, please checkout https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#creating-a-release

6) Update go’s public index for modules

Sometimes it takes some time for the newly released version to be available to download.

In order to make the module available by running the go list command to prompt Go to update its index of modules with information about the module you’re publishing.

Precede the command with a statement to set the GOPROXY environment variable to a Go proxy. This will ensure that your request reaches the proxy.

$ GOPROXY=proxy.golang.org go list -mod=mod -m github.com/arzzon/golang-project-sample/v2@v2.0.0

Or if the proxy doesn't work for any reason, use other proxy servers with the following command:
$ GOPROXY="https://goproxy.io,direct" go list -mod=mod -m github.com/arzzon/golang-project-sample/v2@v2.0.0

NOTE: Update your project name, module version and release version

8) Check index update and usage

We can check whether the go module index got updated successfully, run the following command with the correct version:

curl -k https://proxy.golang.org/github.com/arzzon/golang-project-sample/v2/@v/v2.0.0.info

Note: Update you project names, module version and release version.

Developers interested in your module can import a package from it and run the go get command just as they would do for any other module. They can run the go get command to use the latest released versions or they can specify a particular version, as in the following example:

$ go get github.com/arzzon/golang-project-sample/v2@v2.0.0

Note: Update you project names, module version and release version.

9) Examples for usage of the modules

If you want to use project v2 module in any other project then you need Run the following command to download the package and then simply import it in the go files where ever you want to use it.

$ go get github.com/arzzon/golang-project-sample/v2@v2.1.1
go: downloading github.com/arzzon/golang-project-sample/v2 v2.1.1

Note: Here v2 is module version and v2.1.1 is the 2.1.1 released version of the project

If you want to use v1 module then run the following command

$ go get github.com/arzzon/golang-project-sample
go: downloading github.com/arzzon/golang-project-sample v1.10.1

Note: This will download the last released project with v1 module.

Resources & References:

I hope you find it interesting and useful!!!!😃

Thank you!💖

--

--

Arbaaz Khan

An enthusiastic and self motivated software developer with a knack of achieving results with conviction.