1 #! /bin/bash
2 which goe > /dev/null 2>&1
3
4 if [ $? -eq 0 ]; then
5 echo "exist!"
6
7 else
8 echo "Install go"
9 tarballName=go1.4.2.linux-386.tar.gz
10
11 wget -P /tmp "https://storage.googleapis.com/golang/${tarballName}"
12
13
14 sudo tar -xvf /tmp/${tarballName} -C /usr/local
15
16 cat << 'EOF' >> ~/.bashrc
17 export GOPATH=$HOME/goCode
18 export GOROOT=/usr/local/go
19 export PATH=${GOPATH}/bin:$PATH
20 export PATH=${GOROOT}/bin:$PATH
21 EOF
22
23
24 source ~/.bashrc
25
26 rm -f /tmp/${tarballName}
27 fi
28
29
保存之后 执行bash xxx(文件名即可完成安装配置)
有疑问加站长微信联系(非本文作者)