
Go Version Manager, also known as gvm, allows you to easily manage multiple versions of Go on your system.
With gvm, you can install, update, and delete Go versions with just a few commands.
One of the key benefits of using gvm is that it allows you to switch between different Go versions quickly and easily.
This is particularly useful if you need to work on projects that require different versions of Go.
gvm also provides a simple way to manage your Go environment, making it easier to collaborate with other developers.
What Is a Version Manager?
A version manager is a piece of software that allows you to install and use different software versions quickly without manual installation and configuration.
It's like having a tool that saves you time and effort, and that's exactly what a version manager does.
Great examples of this are the Node Version Manager (NVM) and the Ruby Version Manager (RVM), which are known for their ease of use and flexibility.
Their ability to manage different software versions without requiring administrative privileges is a huge plus, as it simplifies the installation process and makes it more accessible to everyone.
A fresh viewpoint: Microsoft Edge Webview2 Task Manager
Managing Dependencies
Managing dependencies is a crucial aspect of Go development. GVM provides a convenient way to vend native code and dependencies, allowing you to decouple your work from the operating system.
To aid in this process, GVM furnishes several environment variables that can be used to manage dependencies. The ${GVM_OVERLAY_PREFIX} variable can be used as a root directory hierarchy for auto{conf,make,tools}.
The ${PATH} environment variable includes ${GVM_OVERLAY_PREFIX}/bin, making tools you manually install available for use. Runtime library searching can be fulfilled using ${LD_LIBRARY_PATH} on FreeBSD and Linux, and ${DYLD_LIBRARY_PATH} on Mac OS X.
GVM also includes ${PKG_CONFIG_PATH} in its environment variables, which allows pkg-config to automatically resolve vendored dependencies.
Additional reading: Golang Tools
Vendoring Native Code Dependencies
Vendoring Native Code Dependencies is a crucial aspect of maintaining good release engineering and production environment hygiene. It allows you to isolate and qualify new configurations or versions of dependencies in a controlled manner.
GVM provides a convenient way to do this by furnishing environment variables that help decouple your work from the operating system. These variables include ${GVM_OVERLAY_PREFIX}, which serves as a root directory hierarchy for auto{conf,make,tools}.
${GVM_OVERLAY_PREFIX} can be passed to ./configure with the --prefix option, ensuring that it doesn't conflict with existing operating system artifacts. This is particularly useful when working with C and C++ flags.
The ${PATH} environment variable is also modified to include ${GVM_OVERLAY_PREFIX}/bin, making it easy to install and use tools in your workspace.
On FreeBSD and Linux, ${LD_LIBRARY_PATH} is set to include ${GVM_OVERLAY_PREFIX}/lib, allowing runtime library searching to be fulfilled within the vendored dependencies. On Mac OS X, ${DYLD_LIBRARY_PATH} serves a similar purpose.
Finally, ${PKG_CONFIG_PATH} is set to include ${GVM_OVERLAY_PREFIX}/lib/pkgconfig, enabling pkg-config to resolve vendored dependencies automatically.
Here's a summary of the environment variables provided by GVM:
Features and Benefits
With gvm, managing Go versions is a breeze. You can install or uninstall Go versions with a simple command like `gvm install [tag]`, where tag is a specific version like "60.3" or "go1".
One of the most useful features of gvm is its ability to cache a clean copy of the latest Go source, making it easier to install multiple versions. This is especially helpful when you're working on projects that require different versions of Go.
Curious to learn more? Check out: Golang Ci Linter Install
You can also use gvm to manage your GOPATHs with the `gvm pkgset` command. This allows you to create, use, or delete GOPATHs, and even manage repositories under a local path with the `--local` option.
Here are some key features of gvm at a glance:
- Install/Uninstall Go versions with `gvm install [tag]`
- Manage GOPATHs with `gvm pkgset [create/use/delete] [name]`
- Cache a clean copy of the latest Go source
Why Build a Manager? What Are You Solving for?
Building a Version Manager for Go was a personal project that aimed to solve some of the issues I had with the existing installation methods. The main reason was the requirement for an existing installation of Go to install alternate versions, which didn't make sense to me.
One of the main problems with the existing methods was that they required administrative privileges to install Go manually. This meant that even as a developer, I had to use a system directory like /usr/local/, which wasn't ideal.
The existing methods also had other issues, such as not allowing direct use of the go command, requiring manual installation, and not being easy to use. This led to a poor first-time user experience and made it difficult to update the entire environment to an alternate Go version.

Here are some of the key issues with the existing methods:
- Requires an existing installation of Go
- No direct use of the go command
- No simple way to update the entire environment
- Manual installation required administrative privileges
- First-time user experience is not great
- Dependent on package managers like brew or apt
By building a Version Manager, I aimed to create a tool that would solve these issues and make it easier to manage different versions of Go.
Features
ASDF offers several features that make it a powerful tool for managing multiple Go versions. You can install and uninstall Go versions with ease using the command `gvm install [tag]`, where tag is a specific version like "60.3" or "tip".
To manage your GOPATHs, you can use the `gvm pkgset` command, which allows you to create, use, or delete GOPATHs. You can also use the `--local` option to manage a repository under a local path.
One of the most useful features of ASDF is its ability to list added or removed files in GOROOT with the `gvm diff` command. This can be a big help when trying to troubleshoot issues with your Go environment.
Discover more: Golang Test Command

Here are some of the key features of ASDF at a glance:
- Install/Uninstall Go versions with `gvm install [tag]`
- List added/removed files in GOROOT with `gvm diff`
- Manage GOPATHs with `gvm pkgset [create/use/delete] [name]`
- List latest release tags with `gvm listall`
- Cache a clean copy of the latest Go source for multiple version installs
- Link project directories into GOPATH
These features make it easy to manage multiple Go versions and switch between them as needed. With ASDF, you can have multiple versions of Go installed on your system at the same time, which can be a big time-saver when working on different projects.
Advanced Topics
Golang version managers allow for the isolation of multiple versions of Go, enabling developers to work on projects that require different versions of the language.
This is particularly useful when working on legacy projects that may not be compatible with the latest version of Go.
Some popular Golang version managers include GVM and Go Version Manager, which provide a simple and efficient way to manage multiple versions of Go.
These tools can be installed using a simple command, such as `go get -u github.com/moovweb/gvm`, and can be easily updated to ensure compatibility with the latest versions of Go.
Auto Update Process

The auto update process is a game-changer for developers.
You can use the auto-update feature of gvm to automatically check for updates. This feature was created to address the frustration of constantly re-running the install command while debugging.
To use the auto-update feature, a sha256 hash of the current version of gvm is published to the GitHub Releases latest tag.
The auto-update feature then compares the released shasum hash to the current shasum hash. If they don't match, it prompts the user to update, alerting them that a new update is available.
To update Go versions, you can list installed versions using a command.
To install the latest available version, you can use another command.
To update the global version, you can use a third command.
To remove a specific Go version, you can use a command that includes the version number.
Scopes
A .tool-versions file is created in the current directory to record the version used in the current project.
This file is limited in scope to the current directory, so the version will automatically switch when the directory is switched.
You can see the available versions by checking the .tool-versions file, which will list all the versions used in the current project.
Special Cases and Notes
Gorush is not a version manager, it's a tool for building a mobile application with Go. This means it's not suitable for managing different versions of Go.
If you're using a version manager like gvm, you can install multiple versions of Go on your system. For example, you can install Go 1.16 and Go 1.17 at the same time.
However, if you're using a version manager like goreleaser, you'll need to specify the version of Go that you want to use in your project. This can be done by setting the GOROOT environment variable.
Goreleaser also allows you to specify a version of Go that's not currently installed on your system. This can be useful if you want to test your project with a specific version of Go that you don't have installed yet.
You can also use a version manager like glide to manage dependencies in your project. This can be useful if you have a lot of dependencies in your project and want to make sure they're all up to date.
Featured Images: pexels.com


