I am trying to install go in ubuntu. Specifically, install it in Ubuntu 22.04 (Windows WSL2).
I followed the instructions in offcial documentions here (https://go.dev/doc/install).
I downloaded the go package go1.22.3.linux-amd64.tar.gz. And run
$ sudo rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.3.linux-amd64.tar.gz
But it fails and returned
...
tar: go/test/varerr.go: Cannot open: No such file or directory
tar: go: Cannot mkdir: Permission denied
tar: go/test/varinit.go: Cannot open: No such file or directory
tar: go: Cannot mkdir: Permission denied
tar: go/test/winbatch.go: Cannot open: No such file or directory
tar: go: Cannot mkdir: Permission denied
tar: go/test/writebarrier.go: Cannot open: No such file or directory
tar: go: Cannot mkdir: Permission denied
tar: go/test/zerodivide.go: Cannot open: No such file or directory
tar: go: Cannot mkdir: Permission denied
tar: go/test/zerosize.go: Cannot open: No such file or directory
tar: Exiting with failure status due to previous errors
I feel like this is a permission issue in ubuntu. But I already add sudo
command in the first. I don’t know why it still fails. So I wonder if there are another steps I should take.
I tried install go by sudo apt install golang-go
. But the go version it installed is go version go1.18.1 linux/amd64
while I want a latest version. So I am curious how to install it successfully according to the offcial documents.