1. 从官网下载安装包安装
2. 配置国内镜像
# Mac 环境
# 编辑 vi ~/.bash_profile,新增如下
# go start
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
export GOROOT=/usr/local/go
export PATH=${PATH}:/Users/用户名/go/bin
# go end
# source ~/.bash_profile
小提示:在mac环境配置中,${PATH}:xxx 相当于xxx:$PATH,类似代码语法 PATH += xxx;$PATH 与${PATH}等同,如我的.bash_profile文件如下
export PATH=/Users/apple/development/flutter/bin:$PATH
export ANDROID_HOME="/Users/apple/Library/Android/sdk"
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH="$PATH:`yarn global bin`"
# go start
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
export GOROOT=/usr/local/go
export PATH=${PATH}:/Users/apple/go/bin
# go end
3. vscode 安装开发依赖
- command+shift+p 选中go:install/update tools
- 选中全部,点击确定后开始安装