Skip to content

Instantly share code, notes, and snippets.

@snadrus
Last active February 8, 2018 21:43
Show Gist options
  • Save snadrus/02f7875ce6291a7b39e8c5abced5d9c2 to your computer and use it in GitHub Desktop.
Save snadrus/02f7875ce6291a7b39e8c5abced5d9c2 to your computer and use it in GitHub Desktop.
This is an easy way to make sure your Golang builds are always using the latest stable (linux-amd64) compiler in one line of BASH.
Bash:
curl -Ls golang.org/dl | grep -ohm1 htt[^\"]*linux-amd64.tar.gz
Returns just the line of the latest stable linux-amd64 build, like:
https://redirector.gvt1.com/edgedl/go/go1.9.2.linux-amd64.tar.gz
Make a ./go/ with the latest compiler ($GOROOT):
# Get the latest stable GoLang.
cd $GOROOT/..
URL=$(curl -s https://golang.org/dl/ | grep -oh -m1 "https[^\"]*\.linux-amd64.tar.gz")
LATESTDL=$(echo "$URL" | sed -e 's/.*\///')
if [ ! -f $LATESTDL ] ; then
curl -OJL $URL
tar -xzf $LATESTDL
# Makes a "go" folder
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment