Skip to content

Instantly share code, notes, and snippets.

@BuddhiLW
Created July 16, 2024 18:50
Show Gist options
  • Save BuddhiLW/bdeba502cf6d613051dd428e00edcbcf to your computer and use it in GitHub Desktop.
Save BuddhiLW/bdeba502cf6d613051dd428e00edcbcf to your computer and use it in GitHub Desktop.
Install go programatically
#!/usr/bin/bash
GO_FILE=$(wget -O - https://go.dev/dl/ 2>/dev/null | sed -ne 's@.*\(\/go1\.[0-9]*\.[0-9]*\.linux-amd64\.tar\.gz\).*@\1@p' 2>&1 | head -n 1| tr -d /)
URL_DOWNLOAD="https://go.dev/dl/$GO_FILE"
echo "URL_DOWNLOAD=$URL_DOWNLOAD"
wget "$URL_DOWNLOAD"
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf $GO_FILE
echo "Deleating $GO_FILE (Cleaning)"
rm $GO_FILE
echo 'export PATH=$PATH:/usr/local/go/bin'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment