macOS 安装go配置GOROOT GOPATH

在macOS上安装Go语言,通过下载的包安装到/usr/local/go,并确保将/usr/local/go/bin添加到环境变量中。验证安装成功后,配置GOROOT为/usr/local/Cellar/go/1.15.3/libexec,GOPATH设置为个人工作目录如/Users/apple/doc/GoProjects,并更新PATH。还需设置GO111MODULE为on和GOPROXY为阿里云的代理。完成配置后,需要通过source .bash_profile使设置生效。
摘要由CSDN通过智能技术生成
  1. Open the package file you downloaded and follow the prompts to install Go.

    The package installs the Go distribution to /usr/local/go. The package should put the /usr/local/go/bin directory in your PATH environment variable. You may need to restart any open Terminal sessions for the change to take effect.

  2. Verify that you've installed Go by opening a command prompt and typing the following command:
    $ go version
    
  3. Confirm that the command prints the installed version of Go.

3 配置GOROOT、GOPATH、PATH
编辑文件

export GOROOT="/usr/local/Cellar/go/1.15.3/libexec"
export GOPATH="/Users/apple/doc/GoProjects"
export PATH="/Users/apple/doc/GoProjects/bin:$PATH"
export GO111MODULE=on
export GOPROXY=https://mirrors.aliyun.com/goproxy/
 


GOROOT
go 安装目录,此处brew安装,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值