Last active
April 14, 2022 12:53
-
-
Save sattellite/2292c8854267f13d9b20d73e8321413f to your computer and use it in GitHub Desktop.
Updating golang to latest version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Binaries for golang will be placed in /usr/local/go | |
# And /usr/local/go/bin must be in PATH | |
# Put 'export PATH="${PATH}:/usr/local/go/bin"' in shell config | |
# Go version before update | |
go version | |
# Parse url to latest archive for linux | |
fileurl=$(curl -sL https://go.dev/dl/ | egrep 'downloadBox.*linux-amd64' | head -1 | sed -e 's#^.*\(/dl/.*\.tar\.gz\).*#https://golang.org\1#') | |
# Download archive | |
wget ${fileurl} -O golang-latest.tar.gz | |
# Update golang binaries | |
sudo rm -fr /usr/local/go | |
sudo tar -C /usr/local -xzf golang-latest.tar.gz | |
# Remove archive | |
rm -f golang-latest.tar.gz | |
# Go version after update | |
go version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment