Even if it is just from time to time... updating the go version involves some work. Removing the old version, downloading the new version, extracting and installing the new version.
Because we're lazy and after 10 version-updates and typing all the cmds all the time... take this: :)
#! /usr/bin/env bash
if [ -z "$1" ]
then
echo "No go version supplied"
echo "Usage: $0 1.21.1"
echo "Will remove -rf /usr/local/go"
echo "Will download https://go.dev/dl/go1.21.1.linux-amd64.tar.gz"
echo "Will install go1.21.1.linux-amd64.tar.gz to /usr/local/go"
echo "WIll remove local go1.21.1.linux-amd64.tar.gz"
exit 1
fi
GOBALL=go$1.linux-amd64.tar.gz
echo "go version set to $1 / $GOBALL"
sleep 1
echo "removing old go install dir /usr/local/go"
sleep 1
rm -rf /usr/local/go
echo "downloading new tarball: https://go.dev/dl/$GOBALL"
sleep 1
wget https://go.dev/dl/$GOBALL
echo "installing new go version to /usr/local/go"
sleep 1
tar -C /usr/local -xzf $GOBALL
echo "removing local tarball $GOBALL"
rm $GOBALL
sleep 1
NEWVERSION=$(go version)
echo "DONE :) => $NEWVERSION"
exit 0
Save as go-update.sh |> chmod +x |> sudo go-update.sh 1.21.6 #done / profit