dfreire's programming blog home

24 Jun 2015

Using Direnv to setup a Go project based development environment

Go does not ship with a package management tool, so the community has come up with a lot of different approaches for managing dependencies. Some popular ones are: godep, gopkg, and gd.

However, I find that the simple direnv tool works for me.

I simply put a .envrc file like this on my project's root folder and all the go tools work nicely, go get correctly installs packages on the <project_folder>/src, etc.

export GOPATH=<project_folder>
export GOBIN=$GOPATH/bin
export GOROOT=/usr/local/opt/go/libexec
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH

Direnv is language agnostic, so it can be used in other situations as well.