Go 语言教程

MAC 系统使用 VSCode 配置 Go 开发环境

系统软件环境

系统配置:Apple M1 Pro,13.0 (22A380) VSCode 版本: 1.76.1 (Universal) go 版本:go1.20.6 darwin/arm64

配置步骤

  1. 在 VSCode 中设置 go 环境变量 go.goroot

GOPROXY="https://proxy.golang.com.cn,direct"
GOROOT="/opt/homebrew/Cellar/go/1.20.6/libexec"
GOPATH="/Users/hui_zhou/go"
  1. 启用 Use Language Server

  1. 使用 ⌘+⇧+P 快捷键调出命令面板,点击 Go: Install/Update Tools 来安装/更新工具

  2. 使用 go mod 命令来 fix inconsistent vendoring 错误

go mod tidy
go mod vendor