Created
July 7, 2016 23:16
-
-
Save timstclair/17ca792a20e0d83b06dddef7d77b1ea0 to your computer and use it in GitHub Desktop.
GOPATH function
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
# A function for managing multiple Go projects in separate directory hierarchies | |
# Usage: gogo <project name> | |
# Exports variables for use by other scripts or PS1: | |
# __G_PROJECT - aliased project name | |
# __G_PROJECT_DIR - path to project directory in go source tree | |
function gogo() { | |
local PROJECT="$1" | |
local PROJECT_DIR="" | |
local BASE="$HOME/go/$PROJECT" | |
case $PROJECT in | |
k8s*) | |
PROJECT_DIR="$BASE/src/k8s.io/kubernetes" | |
;; | |
heapster) | |
PROJECT_DIR="$BASE/src/k8s.io/heapster" | |
;; | |
cadvisor) | |
PROJECT_DIR="$BASE/src/github.com/google/cadvisor" | |
;; | |
*) | |
echo "Unknown go project '$PROJECT'" 1>&2 | |
return | |
;; | |
esac | |
export GOPATH="$BASE" | |
export __G_PROJECT="$PROJECT" | |
export __G_PROJECT_DIR="$PROJECT_DIR" | |
cd $__G_PROJECT_DIR | |
} | |
alias gg='gogo' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment