Skip to content

Instantly share code, notes, and snippets.

@dimfeld
Last active August 29, 2015 14:01
Show Gist options
  • Save dimfeld/8721fe9cb8145184e797 to your computer and use it in GitHub Desktop.
Save dimfeld/8721fe9cb8145184e797 to your computer and use it in GitHub Desktop.
Bash function to easily set the GOPATH from any subdirectory thereof.
# Embed this function inside your .bashrc or equivalent.
function setgopath() {
# Assume we're in the src directory, and strip off src and everything after it.
DIR=${PWD/src*/}
if [ -d "$DIR/src" -a -d "$DIR/bin" -a -d "$DIR/pkg" ]; then
export GOPATH=$DIR
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment