A simple virtualenv for Go
github.com
github.com
mkdir -p pkg bin src
export GOPATH="`pwd`"
export PATH="$GOPATH/bin:$PATH"
Only what I typed there is shorter and safer than the committed code.That's... simple, yes.
https://github.com/ChuckHa/goenv/tree/inve
I'm not sure I like it better though because it unsets $PS1 and other variables that get set in .bash_profile.
I'm guessing everyone wants something slightly different and it would be pointless for Go to have One Way hence all the alternatives here.
It's very simple and easy to use (there's only one new command), and adding it to a project requires no changes to existing code. We've been using it where I work and it's been very effective.
V1 is going to be released soon, check out the current version at https://github.com/mediocregopher/goat
# active workspace
gvm pkgset use some-workspace
# links current directory to some-workspace/src/github.com/you/foo
gvm linkthis github.com/you/foo
This is more flexible as it allows a common work-in-progress project to be linked to many workspaces.Just add this to your .envrc in your project's folder:
PATH_add bin
GOPATH="$PWD"
The environment is automatically loaded or unloaded whenever you enter or leave the directory.EDIT: Disclaimer, I'm the main author of direnv
It would be nice to standardize this a bit. I'm sure other Go devs I work with use something different (I homerolled for awhile but I've been really pleased with Gobrew).
In my experience, Go developers are generally good about building against updated versions of packages. Combining that with the fact that binaries are all compiled and statically linked (as opposed to dynamically linked or interpreted), I can't remember ever running into the problem where packages X and Y (that I both need) each depend on different versions of Z.
A big advantage of virtualenv in Python isn't relevant here: the ability to specify a specific version of Python (not just 2 vs. 3, but minor versions as well). With Go, you should always be using the most recent version[0] of gc or gccgo, as there is no reason not to.
[0] (If you are someone who actually needs two different versions of the Go gc compiler installed on your system, you're probably on the core dev team, which means you already know what you're doing and already avoid these tools for other reasons.)
It's kind of a pain jumping around distributions manually, which is why I use Gobrew to manage my goandroid Go environment and my normal Go environment.