Skip to content

Instantly share code, notes, and snippets.

@emptyhua
Last active April 4, 2018 02:27
Show Gist options
  • Save emptyhua/658a01c6cdd3ff101253e7701d5ec628 to your computer and use it in GitHub Desktop.
Save emptyhua/658a01c6cdd3ff101253e7701d5ec628 to your computer and use it in GitHub Desktop.
#!/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