Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[BASH] 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