Skip to content

Instantly share code, notes, and snippets.

@boratanrikulu
Last active November 6, 2020 10:43
Show Gist options
  • Save boratanrikulu/e571df351038fdef36bdb2332d305bd0 to your computer and use it in GitHub Desktop.
Save boratanrikulu/e571df351038fdef36bdb2332d305bd0 to your computer and use it in GitHub Desktop.
Installs Go by installing GVM
#!/usr/bin/env bash
GO_VERSION="1.15"
die() {
echo "$*" >&2
exit 444
}
install_go() {
if [[ -s "${HOME}/.gvm/" ]]; then
echo "Gvm was installed."
else
echo ""
echo -en "Gvm will be installed. Do you confirm? [y/n] "
read answer
echo ""
case "$answer" in
"y" ) "Installation will be start. Please do not cancel the operation. Otherwise you system can be broke." ;;
"Y" ) "Installation will be start. Please do not cancel the operation. Otherwise you system can be broke." ;;
"n" ) die "Okay. Update service is cancelled." ;;
"N" ) die "Okay. Update service is cancelled." ;;
* ) echo "Please use only Y or N" ;;
esac
bash < <(zsh -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
fi
if [[ -e "${HOME}/.gvm/gos/go${GO_VERSION}/bin/go" ]]; then
echo "Go was installed."
else
echo ""
echo -en "Go ${GO_VERSION} will be installed. Do you confirm? [y/n] "
read answer
echo ""
case "$answer" in
"y" ) echo "Installation will be start. Please do not cancel the operation. Otherwise you system can be broke." ;;
"Y" ) echo "Installation will be start. Please do not cancel the operation. Otherwise you system can be broke." ;;
"n" ) die "Okay. Update service is cancelled." ;;
"N" ) die "Okay. Update service is cancelled." ;;
* ) echo "Please use only Y or N" ;;
esac
gvm install go${GO_VERSION} && gvm use go${GO_VERSION}
go version
fi
}
main() {
cd ${HOME}
install_go
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment