We’ve been using Google’s new language, Go, for some components in the latest version of our proxy. So far, it’s been a great experience. The language is elegant and fast – just what we need.
When developing an application or a library in Go, one of the frustrating points is keeping up to date with the most recent versions of the language. There can be breaking changes with each release, and to make sure your application is up-to-date you need to upgrade your Go release, run gofix, check the results, and (if needed) revert back to the old version. A lot of hassle!
What’s more, the impending release of Go 1 may present issues for companies that have already built products on top of Go 0. Go 1 has a surprising number of new features that may cause problems in your application. Furthermore, it has an updated package system that may require changing the way your source directories are structured.
For all these reasons – and to help ease the transition – one of our engineers, Josh Bussdieker, has written GVM, a Go version manager. It lets you build different Go versions and easily switch between them. It automatically sets the appropriate environment variables, GOROOT and GOPATH. Want to make sure your application works with Go 1? Want to continue supporting applications written in Go 0? After Go 1 launches, want to keep up to date with the latest weekly releases? GVM is the perfect tool for you!
Let’s take a quick tour of some of GVM’s features.
First, install it from github. Installation is quick (just a one-line script), and you have to add one line to your .bashrc or .bash_profile to enable GVM when your terminal starts.
Once installed, you can take a look at which Go versions are supported by GVM by running:
$> gvm listall
(To see all versions, including weekly, add –all to the end.)
If you want to install a specific version of Go (and then use it), type:
$> gvm install 60.3 $> gvm install weekly.2012-03-13
Use gvm list to list all installed versions. To switch versions, simply run:
$> gvm use 60.3
Or, to use a release by default, use:
$> gvm use 60.3 --default
This tool has made developing with Go a lot easier at Moovweb, where most of our libraries are designed for Go 0 – but we are constantly evaluating Go 1. We hope that you find GVM useful.
GVM has several other features – such as the ability to track changes to your GOROOT (gvm diff). One feature that’s planned for future developments is package sets, which will let you create lists of packages (indicated by a GoPath) and install them quickly.
We hope that GVM makes Go development easier for you. As always, if there are any suggestions, please visit the Github page!