Created
November 22, 2017 15:11
-
-
Save dgnorton/22e26d5cd3e181b0eafa26bccb942bd5 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Source this script from within any directory within a valid potential | |
# GOPATH and it will set it. It looks for the first parent directory | |
# named "go" or "Go" and sets GOPATH to it. | |
c=$(pwd)/dummy | |
while : | |
do | |
d=$(basename $(dirname $c)) | |
if [ "$d" == "/" ]; then | |
echo not a valid GOPATH | |
break | |
elif [ "$d" == "go" ] || [ "$d" == "Go" ]; then | |
export GOPATH=$(dirname $c) | |
export PATH=$PATH:$GOPATH/bin | |
echo GOPATH set to $GOPATH | |
echo Appended $GOPATH/bin to PATH | |
git status | grep "On branch" | |
break | |
else | |
c=$(dirname $c) | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment