Skip to content

Instantly share code, notes, and snippets.

@anthonyaxenov
Last active June 28, 2023 14:07
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 anthonyaxenov/3b5ef7b8f08ed3d06d33e13a48f1c119 to your computer and use it in GitHub Desktop.
Save anthonyaxenov/3b5ef7b8f08ed3d06d33e13a48f1c119 to your computer and use it in GitHub Desktop.
[SHELL] Install golang
#!/bin/bash
# GoLang installer
# https://golang.org/doc/install
# https://www.vultr.com/docs/install-the-latest-version-of-golang-on-ubuntu
# if [ "$EUID" -ne 0 ]
# then echo "*** root permissions required ***"
# exit
# fi
[ $1 ] && VERSION="$1" || VERSION="1.17.5"
FILE="go$VERSION.linux-amd64.tar.gz"
cd /usr/src
sudo rm -rf "$FILE" /usr/local/go
sudo wget "https://golang.org/dl/$FILE"
sudo tar -C /usr/local -xzf "$FILE"
sudo chown $USER: -R /usr/local/go
echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
echo "export GOPATH=~/.go" >> ~/.profile
source ~/.profile
echo "$(go version)"
echo "NOTE: now run \`source ~/.profile\` to apply new env vars"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment