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 My preference is to keep different apps installed in
$HOMEDIR/apps
.Yes,
GOROOT
can be considered and this would be more flexibile.But I think it's misleading to extract the release archive into
$GOROOT/go
(as you put it in the script above:
sudo tar -C "${goroot//go}"
).Currently,
GOROOT
on my side - with the current version - is/home/dxps/apps/go1.20.4
.But if your recently posted script works, that's the whole point! 👏