forked from SchwarzM/k8s-quagga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgoenv
executable file
·91 lines (76 loc) · 2.05 KB
/
goenv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
if [ $# -ne 1 ]; then
TGT="."
else
TGT="$1"
fi
mkdir -p $TGT
cd $TGT
TGT=`pwd`
sed "s|%%TGT%%|$TGT|" > goload << "EOF"
# This file must be used with "source" *from bash*
# you cannot run it directly
gounload () {
unset GOPATH
# reset old environment variables
if [ -n "$_OLD_GODEP_PATH" ] ; then
PATH="$_OLD_GODEP_PATH"
export PATH
unset _OLD_GODEP_PATH
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r 2>/dev/null
fi
if [ -n "$_OLD_GODEP_PS1" ] ; then
PS1="$_OLD_GODEP_PS1"
export PS1
unset _OLD_GODEP_PS1
fi
if [ ! "$1" = "nondestructive" ] ; then
# Self destruct!
unset -f gounload
fi
}
# unset irrelevant variables
gounload nondestructive
SCRIPT_DIR="%%TGT%%"
export GOPATH="`cd $SCRIPT_DIR; pwd`"
_OLD_GODEP_PATH="$PATH"
PATH="$GOPATH/bin:$PATH"
export PATH
if [ -z "$GODEP_ENV_DISABLE_PROMPT" ] ; then
_OLD_GODEP_PS1="$PS1"
if [ "x" != x ] ; then
PS1="$PS1"
else
if [ "`basename \"$GOPATH\"`" = "__" ] ; then
# special case for Aspen magic directories
# see http://www.zetadev.com/software/aspen/
PS1="[`basename \`dirname \"$GOPATH\"\``] $PS1"
else
PS1="(`basename \"$GOPATH\"`)$PS1"
fi
fi
export PS1
fi
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
hash -r 2>/dev/null
fi
# Initialize if not presently set
if [ ! -f $GOPATH/bin/godep ]; then
echo "Fetching godep from github...."
go get github.com/tools/godep
fi
VERSION=`godep version 2> /dev/null`
if [ $? -ne 0 ]; then
echo "Error running godep!"
fi
echo "Loaded godep: $VERSION"
EOF
. goload