How to update the Go version on Ubuntu 20.04

System: Debian/Ubuntu/Fedora. Might work for others as well.

1. Uninstall the existing version

As mentioned here, to update a Go version you will first need to uninstall the original version.

To uninstall the existing Go version, delete the /usr/local/go directory by:

$ sudo rm -rf /usr/local/go

2. Install the new version

Go to the downloads page and download the binary release suitable for your system.

3. Extract the archive file

To extract the archive file, run:

$ sudo tar -C /usr/local -xzf /home/<your-user-on-Ubuntu>/Downloads/go1.18.2.linux-amd64.tar.gz

4. Make sure that your PATH contains /usr/local/go/bin

$ echo $PATH | grep "/usr/local/go/bin"

Leave a Comment

Your email address will not be published. Required fields are marked *