Skip to content

Instantly share code, notes, and snippets.

@renier renier/gowo.sh
Last active Mar 16, 2018

Embed
What would you like to do?
gowo - Go workspace switcher
# Usage: gowo my_go_workspace
# Will set GOPATH and update PATH with the bin dir. Will remove previous GOPATH bin dir from the PATH.
# Opinionated about the root dir where Go workspaces go. Change if you want.
# Put this in your ~/.bash_profile
export GOPATH=$HOME/Projects/go
export PATH=$PATH:$GOPATH/bin
function gowo() {
if [ -n "$GOPATH" ]; then
paths=""
for p in `echo $PATH | sed -e 's/:/ /g'`; do
if [ "$p" != "$GOPATH/bin" ]; then
paths+="$p:"
fi
done
export PATH=`echo $paths | sed -e 's/:$//'`
fi
if [ -z "$1" ]; then
export GOPATH=$HOME/Projects/go
else
export GOPATH=$HOME/Projects/$1
fi
export PATH=$PATH:$GOPATH/bin
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.