go语言的通过安装包搭建环境

rlk@rlk:go$ go get golang.org/x/sys/unix
    go get github.com/tobert/pcstat/pcstat
Command 'go' not found, but can be installed with:

sudo snap install go         # version 1.18.5, or
sudo apt  install golang-go  # version 2:1.13~1ubuntu2
sudo apt  install gccgo-go   # version 2:1.13~1ubuntu2

See 'snap info go' for additional versions.

rlk@rlk:go$     go get github.com/tobert/pcstat/pcstat

Command 'go' not found, but can be installed with:

sudo snap install go         # version 1.18.5, or
sudo apt  install golang-go  # version 2:1.13~1ubuntu2
sudo apt  install gccgo-go   # version 2:1.13~1ubuntu2

See 'snap info go' for additional versions.

通过第一种方法安装失败

rlk@rlk:go$ sudo snap install go
[sudo] password for rlk: 
error: This revision of snap "go" was published using classic confinement and thus may perform
       arbitrary system changes outside of the security sandbox that snaps are usually confined to,
       which may put your system at risk.

       If you understand and want to proceed repeat the command including --classic.

通过第二种方法安装成功

rlk@rlk:go$ sudo apt  install golang-go
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  golang-1.10-go golang-1.10-race-detector-runtime golang-1.10-src golang-race-detector-runtime golang-src
Suggested packages:
  bzr mercurial subversion
The following NEW packages will be installed:
  golang-1.10-go golang-1.10-race-detector-runtime golang-1.10-src golang-go golang-race-detector-runtime
  golang-src
0 upgraded, 6 newly installed, 0 to remove and 6 not upgraded.
Need to get 40.3 MB of archives.
After this operation, 225 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.cn99.com/ubuntu bionic-updates/main amd64 golang-1.10-src amd64 1.10.4-2ubuntu1~18.04.2 [11.1 MB]
Get:2 http://mirrors.cn99.com/ubuntu bionic-updates/main amd64 golang-1.10-go amd64 1.10.4-2ubuntu1~18.04.2 [28.6 MB]
Get:3 http://mirrors.cn99.com/ubuntu bionic/main amd64 golang-1.10-race-detector-runtime amd64 0.0+svn285455-0ubuntu1 [478 kB]
Get:4 http://mirrors.cn99.com/ubuntu bionic/main amd64 golang-src amd64 2:1.10~4ubuntu1 [3,676 B]                
Get:5 http://mirrors.cn99.com/ubuntu bionic/main amd64 golang-go amd64 2:1.10~4ubuntu1 [22.0 kB]                 
Get:6 http://mirrors.cn99.com/ubuntu bionic/main amd64 golang-race-detector-runtime amd64 2:1.10~4ubuntu1 [3,456 B]
Fetched 40.3 MB in 27s (1,505 kB/s)                                                                              
Selecting previously unselected package golang-1.10-src.
(Reading database ... 230565 files and directories currently installed.)
Preparing to unpack .../0-golang-1.10-src_1.10.4-2ubuntu1~18.04.2_amd64.deb ...
Unpacking golang-1.10-src (1.10.4-2ubuntu1~18.04.2) ...
Selecting previously unselected package golang-1.10-go.
Preparing to unpack .../1-golang-1.10-go_1.10.4-2ubuntu1~18.04.2_amd64.deb ...
Unpacking golang-1.10-go (1.10.4-2ubuntu1~18.04.2) ...
Selecting previously unselected package golang-1.10-race-detector-runtime.
Preparing to unpack .../2-golang-1.10-race-detector-runtime_0.0+svn285455-0ubuntu1_amd64.deb ...
Unpacking golang-1.10-race-detector-runtime (0.0+svn285455-0ubuntu1) ...
Selecting previously unselected package golang-src.
Preparing to unpack .../3-golang-src_2%3a1.10~4ubuntu1_amd64.deb ...
Unpacking golang-src (2:1.10~4ubuntu1) ...
Selecting previously unselected package golang-go.
Preparing to unpack .../4-golang-go_2%3a1.10~4ubuntu1_amd64.deb ...
Unpacking golang-go (2:1.10~4ubuntu1) ...
Selecting previously unselected package golang-race-detector-runtime.
Preparing to unpack .../5-golang-race-detector-runtime_2%3a1.10~4ubuntu1_amd64.deb ...
Unpacking golang-race-detector-runtime (2:1.10~4ubuntu1) ...
Setting up golang-1.10-src (1.10.4-2ubuntu1~18.04.2) ...
Setting up golang-1.10-go (1.10.4-2ubuntu1~18.04.2) ...
Setting up golang-1.10-race-detector-runtime (0.0+svn285455-0ubuntu1) ...
Setting up golang-src (2:1.10~4ubuntu1) ...
Setting up golang-race-detector-runtime (2:1.10~4ubuntu1) ...
Setting up golang-go (2:1.10~4ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...

测试

rlk@rlk:go$ go version
go version go1.10.4 linux/amd64
rlk@rlk:go$ 

你可能感兴趣的:(go,linux,go,ubuntu)