get_go.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #! /bin/bash
  2. # [get_golang.sh](https://gist.github.com/n8henrie/1043443463a4a511acf98aaa4f8f0f69)
  3. # Download latest Golang release for AMD64
  4. # https://dl.google.com/go/go1.10.linux-amd64.tar.gz
  5. set -euf -o pipefail
  6. # Install pre-reqs
  7. sudo apt-get install python3 git -y
  8. o=$(python3 -c $'import os\nprint(os.get_blocking(0))\nos.set_blocking(0, True)')
  9. #Download Latest Go
  10. LATEST="$(curl -s https://go.dev/VERSION?m=text)"
  11. DL_PKG="$LATEST.linux-amd64.tar.gz"
  12. DL_URL="https://golang.org/dl/$DL_PKG"
  13. echo "Finding latest version of Go for AMD64..."
  14. echo "Downloading latest Go for AMD64: ${LATEST}"
  15. wget --quiet --continue --show-progress "${DL_URL}"
  16. unset url
  17. unset GOURLREGEX
  18. # Remove Old Go
  19. sudo rm -rf /usr/local/go
  20. # Install new Go
  21. sudo tar -C /usr/local -xzf "${LATEST}".linux-amd64.tar.gz
  22. echo "Create the skeleton for your local users go directory"
  23. mkdir -p ~/go/{bin,pkg,src}
  24. echo "Setting up GOPATH"
  25. echo "export GOPATH=~/go" >> ~/.profile && source ~/.profile
  26. echo "Setting PATH to include golang binaries"
  27. echo "export PATH='$PATH':/usr/local/go/bin:$GOPATH/bin" >> ~/.profile && source ~/.profile
  28. #echo "Installing dep for dependency management"
  29. #go get -u github.com/golang/dep/cmd/dep
  30. # Remove Download
  31. rm "${LATEST}".linux-amd64.tar.gz
  32. # Print Go Version
  33. /usr/local/go/bin/go version
  34. python3 -c $'import os\nos.set_blocking(0, '$o')'