vscode配置go开发环境


安装go vscode git

设置windows用户环境变量

配置go env

# 打开git bash,键入以下命令
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct

vscode配置

# 安装扩展:go和code runner
# 键入ctrl+shift+p 搜:go:install/update
# 选择所有下拉框,点击确定开始安装
# vscode输出以下信息即完成
Tools environment: GOPATH=D:\Dev_Go\GoPath;D:\Dev_Go\workspace
Installing 7 tools at D:\Dev_Go\GoPath\bin;D:\Dev_Go\workspace\bin in module mode.
  gotests
  gomodifytags
  impl
  goplay
  dlv
  staticcheck
  gopls

Installing github.com/cweill/gotests/gotests@latest (D:\Dev_Go\GoPath\bin\gotests.exe) SUCCEEDED
Installing github.com/fatih/gomodifytags@latest (D:\Dev_Go\GoPath\bin\gomodifytags.exe) SUCCEEDED
Installing github.com/josharian/impl@latest (D:\Dev_Go\GoPath\bin\impl.exe) SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay@latest (D:\Dev_Go\GoPath\bin\goplay.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@latest (D:\Dev_Go\GoPath\bin\dlv.exe) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck@latest (D:\Dev_Go\GoPath\bin\staticcheck.exe) SUCCEEDED
Installing golang.org/x/tools/gopls@latest (D:\Dev_Go\GoPath\bin\gopls.exe) SUCCEEDED

All tools successfully installed. You are ready to Go. :)