Navigating the GOPATH
in a terminal can be a pain. Especially if you need to switch between self or company hosted projects and those on GitHub. But, if you set one environment variable it can get a whole lot easier.
export CDPATH=.:$GOPATH/src/github.com:$GOPATH/src/golang.org:$GOPATH/src
You can add this to your shell config or run it yourself. The CDPATH
environment variable containing a colon separated list of paths cd
will try to use when changing directory.
Once I have this set I can change directory like:
$ cd Masterminds/glide
I can do this from anywhere on the system, tab completion works (if you have that setup), and it will take me to the directory (in this case $GOPATH/src/github.com/Masterminds/glide
).