System: Debian/Ubuntu/Fedora. Might work for others as well.
As mentioned here, to update a go version you will first need to uninstall the original version.
To uninstall, delete the /usr/local/go
directory by:
$ sudo rm -rf /usr/local/go
Go to the downloads page and download the binary release suitable for your system.
To extract the archive file:
$ sudo tar -C /usr/local -xzf /home/nikhita/Downloads/go1.8.1.linux-amd64.tar.gz
$ echo $PATH | grep "/usr/local/go/bin"
@theaog Your script is nice and clean. 👏
Since in that release page they also mention about upcoming release, it doesn't work now
(trying to download go1.20.4 which is not yet released at the time of this writing).
A more accurate approach to get the latest release is
wget -qO- "https://golang.org/VERSION?m=text"
I did small adjustments to it, so that it matches my setup, having:
export PATH=$PATH:$HOME/apps/go/bin:$HOME/go/bin
~/apps/bin