说明
使用apt-get 默认仓库安装的版本是1.10,要不就添加仓库安装,要不就下载源码安装。我采用源码安装。
安装
1 2 3 4 5 6 7 8 9 10 11
| root@monitor:~ --2020-12-02 10:38:36-- https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz Resolving dl.google.com (dl.google.com)... 203.208.43.65 Connecting to dl.google.com (dl.google.com)|203.208.43.65|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 123658438 (118M) [application/octet-stream] Saving to: ‘STDOUT’
- 100%[==================================================================================>] 117.93M 11.4MB/s in 9.3s
2020-12-02 10:38:46 (12.6 MB/s) - written to stdout [123658438/123658438]
|
添加环境PATH
PATH1 2 3 4 5
| ```bash root@monitor:~# root@monitor:~# vim /etc/profile root@monitor:~# source /etc/profile
|
检查golang版本
1 2 3
| root@monitor:~ go version go1.14.2 linux/amd64 root@monitor:~
|
编写测试程序
test.go
1 2 3 4 5 6 7 8
| package main
import "fmt"
func main() { fmt.Println("hello world") }
|
编译并执行
1 2 3
| root@monitor:~ root@monitor:~ hello world
|