-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_go.sh
executable file
·55 lines (43 loc) · 1.19 KB
/
install_go.sh
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
#!/usr/bin/env bash
set os
case $OSTYPE in
darwin*) os="darwin" ;;
linux*) os="linux" ;;
*) echo "ERROR unsuported OS $OSTYPE" >&2 ; exit 1 ;;
esac
version="1.12.6"
arch="amd64"
url="https://dl.google.com/go/go${version}.${os}-${arch}.tar.gz"
if [[ -z $GOROOT ]]; then
echo "ERROR GOROOT env var must be set" >&2
exit 1
fi
if [[ -z $GOPATH ]]; then
echo "ERROR GOPATH env var must be set" >&2
exit 1
fi
if [[ -n $GOCACHE ]] && [[ ! -d $GOCACHE ]]; then
mkdir -p $GOCACHE
fi
if [[ -n $GOTMPDIR ]] && [[ ! -d $GOTMPDIR ]]; then
mkdir -p $GOTMPDIR
fi
set -ex
mkdir -p /tmp/install_go
mkdir -p /tmp/install_go/go
curl -fsSL ${url} -o /tmp/install_go/go.tar.gz
tar -C /tmp/install_go/go --strip-components 1 -zxf /tmp/install_go/go.tar.gz
mkdir -p $(dirname $GOROOT)
rm -rf $GOROOT
mv /tmp/install_go/go $GOROOT
rm -rf /tmp/install_go
# Link k8s.io to github.com/kubernetes.
mkdir -p $GOPATH/src
rm -rf $GOPATH/src/k8s.io
rm -rf $GOPATH/src/sigs.k8s.io
mkdir -p $GOPATH/src/github.com/kubernetes
ln -s $GOPATH/src/github.com/kubernetes $GOPATH/src/k8s.io
ln -s $GOPATH/src/kubernetes-sigs $GOPATH/src/sigs.k8s.io
# Uninstall:
#rm -rf $GOROOT/go
#rm -f $GOPATH/{bin,pkg,src}