Last active
March 16, 2018 17:39
-
-
Save renier/2eba43072057172cde88dc9167e7de7b to your computer and use it in GitHub Desktop.
gowo - Go workspace switcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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