Using GVM (Go Version Manager) to Install Golang

I’m starting a project in Go. The first step was obviously to install Go, but after a half hour wrestling with an old and broken installation and a out-of-date PPA, I got fed up.

Then I found gvm. If you’re familiar with rvm for Ruby, I think you’re going to like gvm.

Setup on Ubuntu is pretty simple:

1
$ bash < <(curl -s https://raw.github.com/moovweb/gvm/master/binscripts/gvm-installer)

Then you’ll need to restart your terminal.

Since the install script seems to assume you’re using bash, if you’re using a shell other than bash, you’ll need to add this to your config file (e.g .zshrc, etc):

1
[[ -s "$HOME/.gvm/scripts/gvm" ]] && source "$HOME/.gvm/scripts/gvm"

In my case, I wanted the latest version of Go (1.2 as of this writing), so I ran:

1
2
$ gvm install go1.2
$ gvm use go1.2 --default

The --default flag sets that particular version of go as the default when you open a new terminal session.

It was fun to see that gvm was written by the devs at MoovWeb. When I visited them a few days ago I was interested that they were using Go for their backend – clearly they’re pretty invested!

Comments