Skip to content

Instantly share code, notes, and snippets.

@Zate
Created July 27, 2021 16:11
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 Zate/6d75f95bd389729c0b35838ec1b80e1c to your computer and use it in GitHub Desktop.
Save Zate/6d75f95bd389729c0b35838ec1b80e1c to your computer and use it in GitHub Desktop.
get_go() {
sudo rm -rf /usr/local/go
wget -qO- --show-progress --continue $(wget -qO- https://golang.org/dl/ | grep -oP 'https:\/\/dl\.google\.com\/go\/go([0-9\.]+)\.linux-amd64\.tar\.gz' | head -n 1) | sudo tar zxf - -C /usr/local
echo "Create the skeleton for your local users go directory"
mkdir -p ~/go/{bin,pkg,src}
echo "Setting up GOPATH"
echo "export GOPATH=~/go" >> ~/.profile && source ~/.profile
echo "Setting PATH to include golang binaries"
echo "export PATH='$PATH':/usr/local/go/bin:$GOPATH/bin" >> ~/.profile
source ~/.profile
go version
}
get_go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment