我在安装用于VSCode的Go工具时遇到了一些错误。

huangapple go评论96阅读模式
英文:

I am getting some errors in installing go tools for vscode

问题

我正在尝试为Go语言设置我的Visual Studio Code,但在安装gopls和go-outline时遇到了一些错误。

错误信息如下:

安装github.com/ramya-rao-a/go-outline@latest失败
{
"killed": false,
"code": 1,
"signal": null,
"cmd": "C:\Program Files\Go\bin\go.exe install -v github.com/ramya-rao-a/go-outline@latest",
"stdout": "",
"stderr": "C:\Users\harsh\go\pkg\mod\github.com\ramya-rao-a\go-outline@v0.0.0-20210608161538-9736a4bde949\main.go:14:2: read C:\Users\harsh\go\pkg\mod\golang.org\x\tools@v0.1.1\go\buildutil\allpackages.go: unexpected NUL in input\n"
}

安装golang.org/x/tools/gopls@latest失败
{
"killed": false,
"code": 1,
"signal": null,
"cmd": "C:\Program Files\Go\bin\go.exe install -v golang.org/x/tools/gopls@latest",
"stdout": "",
"stderr": "go: downloading golang.org/x/tools v0.1.11-0.20220407163324-91bcfb1bdf9c\nverifying github.com/sergi/go-diff@v1.1.0: zip: not a valid zip file\n"
}

错误截图如下:
1: https://i.stack.imgur.com/LRTPT.png

是否有其他安装这些工具的方法?

英文:

I am trying to setup my visual studio code for go language. but i am getting some errors in installing gopls and go-outline.

errors

Installing github.com/ramya-rao-a/go-outline@latest FAILED
    {
     "killed": false,
     "code": 1,
     "signal": null,
     "cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v github.com/ramya-rao-a/go-outline@latest",
     "stdout": "",
     "stderr": "C:\\Users\\harsh\\go\\pkg\\mod\\github.com\\ramya-rao-a\\go-outline@v0.0.0-20210608161538-9736a4bde949\\main.go:14:2: read C:\\Users\\harsh\\go\\pkg\\mod\\golang.org\\x\\tools@v0.1.1\\go\\buildutil\\allpackages.go: unexpected NUL in input\n"
    }

Installing golang.org/x/tools/gopls@latest FAILED
{
 "killed": false,
 "code": 1,
 "signal": null,
 "cmd": "C:\\Program Files\\Go\\bin\\go.exe install -v golang.org/x/tools/gopls@latest",
 "stdout": "",
 "stderr": "go: downloading golang.org/x/tools v0.1.11-0.20220407163324-91bcfb1bdf9c\nverifying github.com/sergi/go-diff@v1.1.0: zip: not a valid zip file\n"
}

the screenshot of the errors.

Is there any other way to install this tools ?

答案1

得分: 1

尝试使用以下命令进行操作:

go env -w GO111MODULE=on

然后执行以下命令清理模块缓存:

go clean -modcache

最后重新安装即可。

英文:

try using:

 go env -w GO111MODULE=on

and

go clean -modcache

and install again.

huangapple
  • 本文由 发表于 2022年4月15日 01:20:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/71875484.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定