Warning: This article is outdated and kept here for reference only. From now on I prefer to use GoDeps instead.
Recently, I have been working on different go project and I need to manage different go environment relative to my projects. Coming from ruby and node, I searched for an equivalent of
npm and found gvm (not to be confuse with the Groovy enVironment Manager). GVM offer you a simple way to manage your go version and, more importantly, your
This article aims to explain how I use gvm and how to install it.
GVM is really simple to install, just copy-paste this command and your ready to go (no pun intented).
zsh < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
Note: If you use bash, simply replace zsh with bash.
A package set is a dedicated
$GOPATH, nothing more (well, it can be a little more but it’s not in the scope of this article).
# List available go version (local) gvm list # List available go version (ready to be downloaded) gvm listall # Installing go gvm install go1.3 # Using a version gvm use go1.3 # Creating a pkgset gvm pkgset create my-pkgset-name # Configure environment variables gvm pkgenv my-pkgset-name # Using it gvm pkgset use my-pkgset-name
To be consistent, I prefer to use a pkgset per project. And for each pkgset, I modify the environment (
gvm pkgenv pkgset-name) to include the project directory in the
For example, if I have this directory structure:
~/go project-name src github.com ... googlecode.com ...
I will create a
project-name pkgset and add the path
/home/francois/go/dns-webhook-listener at the end of the $GOPATH variable (via the command
gvm pkgenv project-name).
Note: in the environment file we cannot use the
~ as it will not be expanded.