VSCode安装go相关插件失败的简单解决方案

Oria ·
更新时间:2024-04-29
· 1588 次阅读

 1. GO环境信息

C:\Users\home>go version
go version go1.18.2 windows/amd64
 
C:\Users\home>

安装go插件之后,VSCode开始写代码会提示安装其他插件,错误信息如下:

Installing 8 tools at C:\Go\repository\bin in module mode.
  gotests
  gomodifytags
  impl
  goplay
  dlv
  staticcheck
  gopls
  go-outline
 
Installing github.com/cweill/gotests/gotests@latest FAILED
Installing github.com/fatih/gomodifytags@latest FAILED
Installing github.com/josharian/impl@latest FAILED
Installing github.com/go-delve/delve/cmd/dlv@latest FAILED
Installing github.com/haya14busa/goplay/cmd/goplay@latest FAILED
Installing github.com/go-delve/delve/cmd/dlv@latest FAILED
Installing honnef.co/go/tools/cmd/staticcheck@latest FAILED
Installing honnef.co/go/tools/cmd/staticcheck@latest FAILED
Installing golang.org/x/tools/gopls@latest FAILED
Installing github.com/ramya-rao-a/go-outline@latest FAILED

无法下载插件只能通过设置GOPROXY代理解决

go env -w GOPROXY=https://mirrors.aliyun.com/goproxy/

修改之后

Installing 8 tools at C:\Go\repository\bin in module mode.
  gotests
  gomodifytags
  impl
  goplay
  dlv
  staticcheck
  gopls
  go-outline
 
Installing github.com/cweill/gotests/gotests@latest (C:\Go\repository\bin\gotests.exe) SUCCEEDED
Installing github.com/fatih/gomodifytags@latest (C:\Go\repository\bin\gomodifytags.exe) SUCCEEDED
Installing github.com/josharian/impl@latest (C:\Go\repository\bin\impl.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@latest (C:\Go\repository\bin\dlv.exe) SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay@latest (C:\Go\repository\bin\goplay.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@latest (C:\Go\repository\bin\dlv.exe) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck@latest (C:\Go\repository\bin\staticcheck.exe) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck@latest (C:\Go\repository\bin\staticcheck.exe) SUCCEEDED
Installing golang.org/x/tools/gopls@latest (C:\Go\repository\bin\gopls.exe) SUCCEEDED
 
1 tools failed to install.
 
impl: failed to install impl(github.com/josharian/impl@latest): Error: Command failed: C:\Go\bin\go.exe install -v github.com/josharian/impl@latest
go: github.com/josharian/impl@latest: module github.com/josharian/impl: reading https://mirrors.aliyun.com/goproxy/github.com/josharian/impl/@v/list: 404 Not Found
 
Installing golang.org/x/tools/gopls@latest (C:\Go\repository\bin\gopls.exe) SUCCEEDED
Installing github.com/ramya-rao-a/go-outline@latest FAILED
{
 "killed": false,
 "code": 1,
 "signal": null,
 "cmd": "C:\\Go\\bin\\go.exe install -v github.com/ramya-rao-a/go-outline@latest",
 "stdout": "",
 "stderr": "go: github.com/ramya-rao-a/go-outline@latest: no matching versions for query \"latest\"\n"
}
 
1 tools failed to install.
 
go-outline: failed to install go-outline(github.com/ramya-rao-a/go-outline@latest): Error: Command failed: C:\Go\bin\go.exe install -v github.com/ramya-rao-a/go-outline@latest
go: github.com/ramya-rao-a/go-outline@latest: no matching versions for query "latest"

还是有一个报错,未能成功安装全部插件,然后切换到%GOPATH%\pkg\mod\github.com目录,例如

C:\Go\repository\pkg\mod\github.com

执行如下命令

git clone https://github.com/josharian/impl

 然后切换到GOPATH目录,执行如下命令

PS C:\go\repository> go install github.com/josharian/impl@latest PS C:\go\repository> go install github.com/ramya-rao-a/go-outline@latest go: downloading github.com/ramya-rao-a/go-outline v0.0.0-20210608161538-9736a4bde949 go: downloading golang.org/x/tools v0.1.1 PS C:\go\repository>

 上述命令结束之后,重启VSCode,这下写Go代码就没有问题了。

总结

到此这篇关于VSCode安装go相关插件失败的简单解决方案的文章就介绍到这了,更多相关VSCode安装go插件失败内容请搜索软件开发网以前的文章或继续浏览下面的相关文章希望大家以后多多支持软件开发网!



GO 插件 vscode 解决方案

需要 登录 后方可回复, 如果你还没有账号请 注册新账号