Files
mgmt/misc/go
James Shubin 2ab72bdf94 Allow stubborn users to avoid having to move their project
Some users like to have their project in ~/code/mgmt/ for example, but
this is not compatible with a $GOPATH which is elsewhere. This isn't a
problem unless you need vendored directories in ~/code/mgmt/vendor/
which doesn't work because ~/code/mgmt/ isn't in $GOPATH. With this
symlink and the provided ~/bin/go wrapper, vendored directories work
exactly as expected, and we also get a local $GOPATH pointing to the
same thing. Since $GOPATH must have a src/ dir, and vendor/ must NOT,
then we symlink the two together accordingly.

An important part of this is that those who like to put everything in
$GOPATH won't be affected by any of this!
2016-04-04 01:25:23 -04:00

13 lines
585 B
Bash
Executable File

#!/bin/bash
# hack around stupid $GOPATH semantics, with ~/bin/go helper
# thanks to Nilium in #go-nuts for 1/3 of the idea
[ -z "$GOPATH" ] && echo '$GOPATH is not set!' && exit 1
GO="$(which -a go | sed -e '2q;d')" # TODO: pick /usr/bin/go in a better way
# the idea is to have $project/gopath/src/ be a symlink to ../vendor but you put
# all of your vendored things in vendor/ but with this gopath can be per project
if [ -d "$PWD/vendor/" ] && [ -d "$PWD/gopath/" ] && [ "`readlink $PWD/gopath/src`" = "../vendor" ] ; then
GOPATH="$PWD/gopath/:$GOPATH" $GO "$@"
else
$GO "$@"
fi