66 lines
1.2 KiB
Bash
Executable file
66 lines
1.2 KiB
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
|
|
|
|
INSTALL="/usr/local"
|
|
GITHUB="https://github.com/golang/go/archive"
|
|
|
|
V14="go1.4.3"
|
|
bootstrap="${INSTALL}/bootstrap-${V14}"
|
|
TGZ14="${V14}.tar.gz"
|
|
|
|
Vnew="go1.8"
|
|
TGZnew="${Vnew}.tar.gz"
|
|
|
|
rm -rf ${INSTALL}/go*
|
|
|
|
if [ ! -d "${bootstrap}" ]; then
|
|
wget -q ${GITHUB}/${TGZ14} -O ${INSTALL}/${TGZ14}
|
|
tar xfz ${INSTALL}/${TGZ14} -C ${INSTALL}
|
|
mv ${INSTALL}/go-${V14} ${bootstrap}
|
|
fi
|
|
|
|
wget -q ${GITHUB}/${TGZnew} -O ${INSTALL}/${TGZnew}
|
|
tar xfz ${INSTALL}/${TGZnew} -C ${INSTALL}
|
|
mv ${INSTALL}/go-${Vnew} ${INSTALL}/${Vnew}
|
|
|
|
export CGO_ENABLED=0
|
|
|
|
if [ ! -x "${bootstrap}/bin/go" ]; then
|
|
cd ${bootstrap}/src
|
|
./make.bash &> /dev/null
|
|
fi
|
|
|
|
export GOROOT_BOOTSTRAP=${bootstrap}
|
|
|
|
if [ "$(uname -m)" == "x86_64" ]; then
|
|
export GOARCH=amd64
|
|
else
|
|
export GOARCH=386
|
|
fi
|
|
|
|
cd ${INSTALL}/${Vnew}/src
|
|
./make.bash &> /dev/null
|
|
|
|
rm -rf ${INSTALL}/go
|
|
mv ${INSTALL}/${Vnew} ${INSTALL}/go
|
|
#ln -s ${INSTALL}/go ${INSTALL}/${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
|