系统:macOS Big Sur 11.2.1
IDE: VSCode
命令行:brew install go (需要科学上网)
vscode插件安装:go,golang postfix code completion
坑1:之后vscode随意打开一个go文件会提示安装golang插件依赖,此时安装失败
Installing 7 tools at /Users/xx/go/bin in module mode.
需要命令行运行:
$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn,direct
坑2:尝试在go文件写入
package main
会报错 gopls requires a module at the root of your workspace
需要编辑setting文件添加:
“gopls”: {
“experimentalWorkspaceModule”: true
}