How can the existing version of go
be updated using the go install
command?
I've done the following
$ go install golang.org/dl/go1.19.4@latest
go: downloading golang.org/dl v0.0.0-20221207214018-bd7282711064
$ go1.19.4 download
Downloaded 0.0% ( 16384 / 148931745 bytes) ...
Downloaded 9.2% ( 13647776 / 148931745 bytes) ...
Downloaded 36.2% ( 53870192 / 148931745 bytes) ...
Downloaded 61.8% ( 92028240 / 148931745 bytes) ...
Downloaded 87.4% (130137120 / 148931745 bytes) ...
Downloaded 100.0% (148931745 / 148931745 bytes)
Unpacking /home/gameveloster/sdk/go1.19.4/go1.19.4.linux-amd64.tar.gz ...
Success. You may now run 'go1.19.4'
$ which go1.19.4
/home/gameveloster/go/bin/go1.19.4
$ which go
/home/gameveloster/.go/bin/go
Is the final step to copy the newly downloaded go
binary ~/go/bin/go1.19.4
to replace the existing ~/.go/bin/go
?
Is there a special way to then clean up ~/go/bin/go1.19.4
, or is simply deleting this binary sufficient?
CodePudding user response:
How can the existing version of go be updated using the go install command?
Not. That's simply not the way to manage the installation of Go. Being able to "go install" a certain version is a nice shortcut to get a certain version of Go up and running but it's not the intended way to manage "the" Go installation on your machine.
CodePudding user response:
The short answer is No you can't update the existing version of go. First, you have to uninstall the currently installed version and then install a newer version. Here is an easy solution,
To find the installation address run
where go
To uninstall, delete the given address of above,
sudo rm -rf [output of above command]
To check if you already remove go, run the below command; the system will prompt "command go not found"
go --version
Now install a newer version of go
wget https://go.dev/dl/go1.19.4.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz
Make sure that your PATH contains /usr/local/go/bin
export PATH=$PATH:/usr/local/go/bin
After that, you will need to restart your terminal for the change to take effect. To check if you have installed Go successfully, run the below command.
go --version
Enjoy!