Skip to content

Instantly share code, notes, and snippets.

@benwei
Last active April 5, 2020 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benwei/b350d74fd8ec85bccc00c7712389daad to your computer and use it in GitHub Desktop.
Save benwei/b350d74fd8ec85bccc00c7712389daad to your computer and use it in GitHub Desktop.
simple script to install golang for Linux Debian or Ubuntu
#!/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