在 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.***/josharian/impl@v1.1.0 FAILED
{
"code": 1,
"killed": false,
"signal": null,
"cmd": "C:\\Program Files (x86)\\Go\\bin\\go.exe install -v github.***/josharian/impl@v1.1.0",
"stdout": "",
"stderr": "go: downloading golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375\nC:\\code\\go\\pkg\\mod\\github.***\\josharian\\impl@v1.1.0\\impl.go:20:2: zip: not a valid zip file\n"
}
gopls: failed to install gopls(golang.org/x/tools/gopls@latest): Error: ***mand 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.***/josharian/impl@v1.1.0): Error: ***mand failed: C:\Program Files (x86)\Go\bin\go.exe install -v github.***/josharian/impl@v1.1.0
go: downloading golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375
C:\code\go\pkg\mod\github.***\josharian\impl@v1.1.0\impl.go:20:2: zip: not a valid zip file
尝试了一些方法都没有生效,包括使用 go clean -modcache命令。
最后通过切换代理源
go env -w GOPROXY=https://goproxy.***,direct
从阿里代理源切换为 goproxy.***,direct
再使用 go clean -modcache 命令
最后安装成功