65 lines
1,009 B
Bash
Executable file
65 lines
1,009 B
Bash
Executable file
#!/bin/bash
|
|
|
|
set -e
|
|
if [ ${EUID} -ne 0 ]; then
|
|
echo "error: this script must be run as root" 1>&2
|
|
exit 1
|
|
fi
|
|
|
|
GITHUB="https://github.com/golang/go/archive/"
|
|
|
|
V14="go1.4.3"
|
|
TGZ14="${V14}.tar.gz"
|
|
|
|
Vnew="go1.7.4"
|
|
TGZnew="${Vnew}.tar.gz"
|
|
|
|
INSTALL="/usr/local"
|
|
|
|
cd ${INSTALL}
|
|
|
|
rm -rf go*
|
|
|
|
wget -q ${GITHUB}${TGZ14}
|
|
tar xfz ${TGZ14}
|
|
mv go-${V14} ${V14}
|
|
|
|
wget -q ${GITHUB}${TGZnew}
|
|
tar xfz ${TGZnew}
|
|
mv go-${Vnew} ${Vnew}
|
|
|
|
export CGO_ENABLED=0
|
|
|
|
cd ${INSTALL}/${V14}/src
|
|
./make.bash &> /dev/null
|
|
|
|
export GOROOT_BOOTSTRAP=${INSTALL}/${V14}
|
|
|
|
if [ "$(uname -m)" == "x86_64" ]; then
|
|
export GOARCH=amd64
|
|
else
|
|
export GOARCH=386
|
|
fi
|
|
|
|
cd ${INSTALL}/${Vnew}/src
|
|
./make.bash &> /dev/null
|
|
|
|
cd ${INSTALL}
|
|
rm -rf go
|
|
mv ${Vnew} go
|
|
ln -s /usr/local/go /usr/local/go${Vnew}
|
|
|
|
export GOROOT=${INSTALL}/go
|
|
export PATH=${PATH}:${GOROOT}/bin:~/go/bin
|
|
|
|
cat <<EOF
|
|
add this to your .bashrc/.profile:
|
|
|
|
export CGO_ENABLED=${CGO_ENABLED}
|
|
export GOPATH=~/go
|
|
export GOROOT=${GOROOT}
|
|
export PATH=\${PATH}:${GOROOT}:~/go/bin
|
|
|
|
EOF
|
|
|
|
go version
|