#! /bin/bash # [get_golang.sh](https://gist.github.com/n8henrie/1043443463a4a511acf98aaa4f8f0f69) # Download latest Golang release for AMD64 # https://dl.google.com/go/go1.10.linux-amd64.tar.gz set -euf -o pipefail # Install pre-reqs sudo apt-get install python3 git -y o=$(python3 -c $'import os\nprint(os.get_blocking(0))\nos.set_blocking(0, True)') #Download Latest Go LATEST="$(curl -s https://go.dev/VERSION?m=text)" DL_PKG="$LATEST.linux-amd64.tar.gz" DL_URL="https://golang.org/dl/$DL_PKG" echo "Finding latest version of Go for AMD64..." echo "Downloading latest Go for AMD64: ${LATEST}" wget --quiet --continue --show-progress "${DL_URL}" unset url unset GOURLREGEX # Remove Old Go sudo rm -rf /usr/local/go # Install new Go sudo tar -C /usr/local -xzf "${LATEST}".linux-amd64.tar.gz 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 #echo "Installing dep for dependency management" #go get -u github.com/golang/dep/cmd/dep # Remove Download rm "${LATEST}".linux-amd64.tar.gz # Print Go Version /usr/local/go/bin/go version python3 -c $'import os\nos.set_blocking(0, '$o')'