普拉多VX

人生一路,不问来时,不知归期

0%

Ubuntu 18.04 安装 golang 1.14

说明

使用apt-get 默认仓库安装的版本是1.10,要不就添加仓库安装,要不就下载源码安装。我采用源码安装。

安装

1
2
3
4
5
6
7
8
9
10
11
root@monitor:~# wget -c https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local #下载并解压到/usr/local/目录下
--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

PATH
1
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
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:~# go build test.go 
root@monitor:~# ./test
hello world