Last active
April 4, 2018 02:27
-
-
Save emptyhua/658a01c6cdd3ff101253e7701d5ec628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ver=$1 | |
plat=$(uname -s) | |
plat=${plat,,} | |
arch=$(uname -m) | |
arch=${arch,,} | |
case $arch in | |
"i686") | |
arch="386" | |
;; | |
"x86_64") | |
arch="amd64" | |
;; | |
esac | |
echo $plat, $arch | |
setupbashrc() { | |
sed -i "/GOROOT/d" ~/.bashrc | |
sed -i "/GOPATH/d" ~/.bashrc | |
echo "export GOPATH=/gohome" >> ~/.bashrc | |
echo "export GOROOT=/opt/go${ver}" >> ~/.bashrc | |
echo "export PATH=\$GOPATH/bin:\$GOROOT/bin:\$PATH" >> ~/.bashrc | |
} | |
cd /tmp | |
test -d ./go && rm -rf ./go | |
wget "https://dl.google.com/go/go${ver}.${plat}-${arch}.tar.gz" -O ./go.tar.gz && \ | |
tar -zxf ./go.tar.gz && \ | |
mv ./go /opt/go${ver} && \ | |
setupbashrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment