1.安装golang解释器
从网址https://go.dev/dl/下载对应的golang解释器
2.配置环境
- Extensions中搜索安装go
2.配置settings.json
{
"go.autocompleteUnimportedPackages": true,
"go.gocodeAutoBuild": false,
"explorer.confirmPasteNative": false,
"files.autoSave": "onFocusChange",
"redhat.telemetry.enabled": true,
"go.gopath": "",
"go.goroot": "F:\\Program Files\\Go"
}
go.goroot 为go解释器安装目录
3.安装插件
按下ctrl+shift + p,输入go
选择 install/Update Tools,全部勾选安装
4.插件安装失败
链接不上国外服务器,通过命令行输入,重启vscode,再次安装插件即可
go env -w GOPROXY="https://goproxy.cn"