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?
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
To uninstall, delete the given address of above,
To check if you already remove go, run the below command; the system will prompt "command go not found"
Now install a newer version of go
Make sure that your PATH contains /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.
Enjoy!