Last active
April 5, 2020 07:09
-
-
Save benwei/b350d74fd8ec85bccc00c7712389daad to your computer and use it in GitHub Desktop.
simple script to install golang for Linux Debian or Ubuntu
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 | |
install_go_linux() | |
{ | |
sudo add-apt-repository ppa:longsleep/golang-backports | |
sudo apt update | |
sudo apt install -y golang-go | |
ret=$? | |
if [ $ret -eq 0 ]; then | |
go version | |
else | |
echo "Fail to install golang, please check your environment (exit code=$ret)" | |
fi | |
return $ret | |
} | |
main() | |
{ | |
which lsb_release | |
if [ $? -ne 0 ]; then | |
echo "unknown operation system for this install script." | |
return 1 | |
fi | |
lsb_codename=`lsb_release -i -s` | |
case $lsb_codename in | |
Debian|Ubuntu) | |
install_go_linux | |
return $? | |
;; | |
*) | |
echo "The script is not tested with $lsb_codename" | |
;; | |
esac | |
return 1 | |
} | |
main $@ | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment