
3

CentOS或macOS安装GoLang
source link: https://pengrl.com/p/34426/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

CentOS或macOS安装GoLang
发表于 2019-03-29 | 分类于 环境搭建|工具使用
| 字数统计: 382
安装GoLang编译器有两种方式:
- 下载编译好的无第三方依赖的二进制文件
我们普通用户使用第二种方式比较简单,操作都是傻瓜式的。
打开GoLang官方下载页面 https://golang.org/dl/ ,找最新版本的GoLang压缩包,以我现在的时间2021年1月31号为例,最新版本是go1.15.7。我的centos需要OS为Linux,Arch为x86-64的包。
注意,如果官网被墙了打不开,也可以上Go语言中文网上下载相应的镜像文件,地址: https://studyGoLang.com/dl
# 1. 下载
$wget https://dl.google.com/go/go1.15.7.linux-amd64.tar.gz
# 如果没有wget,也可以使用curl
$curl -O https://dl.google.com/go/go1.15.7.linux-amd64.tar.gz
# 2. 解压
$tar zxvf go1.15.7.linux-amd64.tar.gz -C /usr/local
# 3. 在/etc/profile文件末尾添加需要的环境变量
export GOROOT=/usr/local/go
export GOPATH=/usr/local/gopath
export PATH=$PATH:$GOROOT/bin
# 4. 使当前shell环境变量立即生效
$source /etc/profile
# 5. 检查是否安装成功
$go version
# 在我的机器上输出如下结果,表示已成功安装1.15.7版本的GoLang
go version go1.15.7 linux/amd64
之后我们就可以编译Go语言编写的程序了。
macOS安装方式几乎和CentOS一样,只是下载安装包的时候换成go1.15.7.darwin-amd64.tar.gz
参考链接
本文完,作者yoko,尊重劳动人民成果,转载请注明原文出处: https://pengrl.com/p/34426/
推荐阅读:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK