解决VSCode中安装Go环境Gopls失败的问题

问题

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
相关推荐
圣殿骑士-Khtangc15 小时前
Go字符串高效拼接性能对比与底层原理分析
服务器·前端·golang
2401_8582861117 小时前
VSCODE远程链接错误: 无法建立链接,过程试图写入的管道不存在的解决方法
ide·vscode·编辑器
像风一样自由202017 小时前
加强版VScode结合remote-ssh远程连接服务器开发指南
服务器·vscode·ssh
一朵好运莲18 小时前
Turbo Console Log插件VSCode更改log快捷键教程
ide·vscode·编辑器
xzlAwin19 小时前
Win10安装Go语言多版本管理器g工具
开发语言·golang
FfHUCisI1 天前
Golang RESTful API 设计原则
开发语言·golang·restful
大可-1 天前
Go Air 热重载安装配置指南
开发语言·后端·golang
Zenova EdgeOS1 天前
工业边缘 SDK 设计实战:从 API 到 Python/Go 多语言工程落地
python·golang·php
名字还没想好☜2 天前
Go 的 unsafe.Pointer 实战:零拷贝 []byte↔string 转换与三条铁律
开发语言·后端·golang·go·unsafe
xzlAwin2 天前
Go语言多版本管理器g工具命令
开发语言·golang