Skip to content

Instantly share code, notes, and snippets.

@tiagocesar
Last active October 23, 2023 15:43
Show Gist options
  • Save tiagocesar/1f843fefd5f08497344d622a3f4b56a4 to your computer and use it in GitHub Desktop.
Save tiagocesar/1f843fefd5f08497344d622a3f4b56a4 to your computer and use it in GitHub Desktop.
Update Go to the latest version
# Updates Go to the latest version
update_go() {
latest_go_version=`curl -L https://go.dev/VERSION\?m\=text | cut -f3 -d ' '`
current_go_version=`go version 2>/dev/null | cut -f3 -d ' '`
if [ "$current_go_version" != "$latest_go_version" -a "$latest_go_version" != "" ]; then
echo "* Updating Go to version $latest_go_version (from $current_go_version)"
sudo sh -c "rm -fr /usr/local/go && curl -C - --silent https://dl.google.com/go/${latest_go_version}.darwin-arm64.tar.gz |tar -C /usr/local -xzf -"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment