【Go】vs code安装 install/update tools 遇到zip: not a valid zip file

在 vs code 安装 go 工具包 gopls 或 impl时遇到报错

Installing golang.org/x/tools/gopls@latest FAILED
{
 "code": 1,
 "killed": false,
 "signal": null,
 "cmd": "C:\\Program Files (x86)\\Go\\bin\\go.exe install -v golang.org/x/tools/gopls@latest",
 "stdout": "",
 "stderr": "go: downloading golang.org/x/tools/gopls v0.14.2\ngo: golang.org/x/tools/gopls@latest: zip: not a valid zip file\n"
}
Installing github.com/josharian/[email protected] FAILED
{
 "code": 1,
 "killed": false,
 "signal": null,
 "cmd": "C:\\Program Files (x86)\\Go\\bin\\go.exe install -v github.com/josharian/[email protected]",
 "stdout": "",
 "stderr": "go: downloading golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375\nC:\\code\\go\\pkg\\mod\\github.com\\josharian\\[email protected]\\impl.go:20:2: zip: not a valid zip file\n"
}
gopls: failed to install gopls(golang.org/x/tools/gopls@latest): Error: Command failed: C:\Program Files (x86)\Go\bin\go.exe install -v golang.org/x/tools/gopls@latest
go: downloading golang.org/x/tools/gopls v0.14.2
go: golang.org/x/tools/gopls@latest: zip: not a valid zip file
 
impl: failed to install impl(github.com/josharian/[email protected]): Error: Command failed: C:\Program Files (x86)\Go\bin\go.exe install -v github.com/josharian/[email protected]
go: downloading golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375
C:\code\go\pkg\mod\github.com\josharian\[email protected]\impl.go:20:2: zip: not a valid zip file

尝试了一些方法都没有生效,包括使用 go clean -modcache命令。

最后通过切换代理源

go env -w GOPROXY=https://goproxy.cn,direct

从阿里代理源切换为 goproxy.cn,direct
再使用 go clean -modcache 命令
最后安装成功

【Go】vs code安装 install/update tools 遇到zip: not a valid zip file_第1张图片

你可能感兴趣的:(Go,golang,开发语言,后端)