-
Notifications
You must be signed in to change notification settings - Fork 1
/
installGo
30 lines (18 loc) · 884 Bytes
/
installGo
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
#!/usr/bin/env bash
# https://golang.org/doc/install#install
# After installing the new version, the tool chain is installed again using the new compiler
INSTALL_VERSION=${1:-1.8}
OS=linux
ARCH=armv6l
if type go > /dev/null 2>&1 && [[ "$(go version 2>/dev/null)" =~ $INSTALL_VERSION ]] ;then
echo $(go version) already installed at $(go env GOROOT)
exit 2
fi
[ -d /usr/local/go ] && sudo rm -rf /usr/local/go
wget -O - https://storage.googleapis.com/golang/go${INSTALL_VERSION}.${OS}-${ARCH}.tar.gz | sudo tar -xzC /usr/local -f -
echo '# Setup for golang' |sudo tee /etc/profile.d/golang.sh > /dev/null
echo 'PATH=$PATH:/usr/local/go/bin'|sudo tee -a /etc/profile.d/golang.sh > /dev/null
source /etc/profile.d/golang.sh
echo Now installing the Go tools
sudo -i GOPATH=/tmp GOBIN=$(go env GOROOT)/bin go get -u golang.org/x/tools/...
echo $(go version) installed