当前位置:   article > 正文

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

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"
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
Installing github.com/josharian/impl@v1.1.0 FAILED
{
 "code": 1,
 "killed": false,
 "signal": null,
 "cmd": "C:\\Program Files (x86)\\Go\\bin\\go.exe install -v github.com/josharian/impl@v1.1.0",
 "stdout": "",
 "stderr": "go: downloading golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375\nC:\\code\\go\\pkg\\mod\\github.com\\josharian\\impl@v1.1.0\\impl.go:20:2: zip: not a valid zip file\n"
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
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/impl@v1.1.0): Error: Command failed: C:\Program Files (x86)\Go\bin\go.exe install -v github.com/josharian/impl@v1.1.0
go: downloading golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375
C:\code\go\pkg\mod\github.com\josharian\impl@v1.1.0\impl.go:20:2: zip: not a valid zip file
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

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

最后通过切换代理源

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

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

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/890144
推荐阅读
相关标签
  

闽ICP备14008679号