Created
June 6, 2014 17:43
-
-
Save oremj/81ccad571c4c3fb2622e to your computer and use it in GitHub Desktop.
Like python virtualenv for go.
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
GO_WORKSPACE=${GO_WORKSPACE:-~/Documents/work/goworkspace} | |
mkdir -p $GO_WORKSPACE | |
goworkon() { | |
PROJECT=$1 | |
PROJECT_DIR="${GO_WORKSPACE}/${PROJECT}" | |
if [[ ! -d "$PROJECT_DIR" ]]; then | |
echo "Project does not exist!" | |
return 1 | |
fi | |
export GOPATH=$PROJECT_DIR | |
export GOBIN="${PROJECT_DIR}/bin" | |
cd $PROJECT_DIR | |
cd "$(readlink ./link)" | |
} | |
gocreateproject() { | |
GITHUB=$1 | |
GITHUB_PATH=github.com/${GITHUB#*:} | |
PROJECT=${GITHUB##*/} | |
PROJECT_DIR="${GO_WORKSPACE}/${PROJECT}" | |
if [[ -d "$PROJECT_DIR" ]]; then | |
echo "Project alread exists!" | |
return 1 | |
fi | |
mkdir -p "${PROJECT_DIR}/src" | |
cd ${PROJECT_DIR} | |
git clone "${GITHUB}.git" "src/${GITHUB_PATH}" || return 1 | |
ln -snf "src/${GITHUB_PATH}" link | |
goworkon "$PROJECT" | |
} | |
func _goworkon() { | |
reply=( `cd "$GO_WORKSPACE"; ls` ) | |
} | |
compctl -K _goworkon goworkon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment