Last active
March 2, 2016 21:55
-
-
Save selam/e3449c075fd047d32454 to your computer and use it in GitHub Desktop.
auto add current directory in to GOPATH
This file contains hidden or 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
export GOPATH="$HOME/.go" | |
_gopath_auto_activate() { | |
if [ -e "main.go" ]; then | |
# Check to see if already activated to avoid redundant activating | |
FINDED=false | |
PWD=$(pwd -P) | |
array=(${GOPATH//:/ }) | |
for p in "${!array[@]}"; do | |
if [[ "${array[p]}" == "$PWD" ]]; then | |
FINDED=true | |
fi; | |
done; | |
if [[ $FINDED != true ]]; then | |
export GOPATH="$GOPATH:$PWD" | |
fi; | |
fi | |
} | |
export PROMPT_COMMAND=_gopath_auto_activate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment