环境:
- VMware 15.5.1中安装的 Ubuntu 18
安装
-
终端执行命令
sudo apt-get install golang
-
安装完成后你可以查看版本号,这里默认安装最新版本
-
配置环境变量,执行
sudo gedit /etc/profile
将下面代码添加至 /etc/profile文件末尾,(也可以添加至 ~/.bashrc文件里)export GOPATH=/home/GO_PATH //用于go的工作目录 export GOROOT=/usr/lib/go-1.10 //安装目录 PATH=$GOROOT/bin:$PATH
每个人的安装可能目录不一样,所以要适当更改。
然后生效更改source /etc/profile . /etc/profile
-
检测是否成功
go env