I was using Go version 1.13.8 which is latest if you install it using "apt-get install golang-go" command on linux mint or ubuntu.
Now I wanted to use generics and kafka-go package, which is not available for Go version less that 1.18 and 1.15 respectively.
So I decided to upgrade the Go version. But as I surf through the internet, I was not able to find a concrete solution for this.
So after much surfing and trial and error, here is the procedure I followed:
If you have installed the Go using above method, then:
first remove the older version using:
sudo apt-get remove golang-go
sudo apt-get remove --auto-remove golang-go
The above command must have uninstall the older version of Go from your system. Check it using
Now,If it is present, delete the go folder from usr/local.
After that, get the latest version file of Go for Linux(It was 1.18.4 at the time of writing this blog) using:
Manually untar it or use tar command as:
tar -xvf go1.18.4.linux-amd64.tar.gz
and move it to usr/local, manually using "Files" or using command:
mv go /usr/local
Now this has been taken care of, we have to define the GOROOT, GOPATH and PATH variables in profile file. For system wide permanent effect copy following three lines and paste them into /etc/profile file:
export GOROOT=/usr/local/go export GOPATH=$HOME/<path to where your all go projects lies> export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
OR, if you want the changes for that particular session, you can run above "export" commands in your terminal.
Now check go version, it should show you the one you installed.
Thanks for reading!