官方下载地址
1 | https://go.dev/dl/ |
1.下载pkg版本的安装包,直接双击安装,比如
1 | https://go.dev/dl/go1.20.12.darwin-amd64.pkg |
这时默认的GOPATH路径(go依赖的下载路径)在~/go
2.也可以下载tar的压缩包进行安装
下载mac对应的安装版,intel版本的mac下载x86版本
1 | https://go.dev/dl/go1.20.12.darwin-amd64.tar.gz |
解压到/usr/local目录
1 | sudo tar -xzvf go1.20.12.darwin-amd64.tar.gz -C /usr/local |

配置环境变量
1 | # go |
其中
1 | GOPATH: go工作区, 下载的依赖会存放在此目录中,默认会在~/go目录下 |
在GOPATH
工作区目录下,有3个目录
1 | bin: 存储可执行bin文件 |
source配置
1 | source ~/.bash_profile |
验证安装版本
1 | go version |
参考:mac下安装go开发环境
如果在Goland中遇到报错:Unresolved dependency
可以在勾选Enable Go modules integration来解决
