问题
bash
# vscode报错
The "goimports" command is not available. Run "go install -v golang.org/x/tools/cmd/goimports@latest" to install.
# 终端输出
[error] gopls: failed to install gopls(golang.org/x/tools/gopls@latest): Error: Command failed: /usr/local/go/bin/go install -v golang.org/x/tools/gopls@latest
go: golang.org/x/tools/gopls@latest: invalid proxy URL missing scheme: direc
```
# 解决方法
在终端中运行以下命令:
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
这将修改Go模块的代理设置,使用国内的代理服务器来获取Go模块。
# 参考
https://developer.baidu.com/article/details/2830359