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

 更新时间:2023年07月10日 09:58:56   作者:mlwise  
这篇文章主要给大家介绍了关于VSCode安装go相关插件失败的简单解决方案,VSCode是我们开发go程序的常用工具,最近安装的时候遇到了些问题,需要的朋友可以参考下

 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中strings的常用方法详解

    Go中strings的常用方法详解

    这篇文章主要介绍了Go中strings的常用方法详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-03-03
  • go程序部署到linux上运行的实现方法

    go程序部署到linux上运行的实现方法

    本文主要介绍了go程序部署到linux上运行的实现方法,文中通过示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-04-04
  • Go语言计算指定年月天数的方法

    Go语言计算指定年月天数的方法

    这篇文章主要介绍了Go语言计算指定年月天数的方法,实例分析了Go语言操作时间的技巧,具有一定参考借鉴价值,需要的朋友可以参考下
    2015-02-02
  • Golang 1.16 中 Modules的主要变化更新

    Golang 1.16 中 Modules的主要变化更新

    这篇文章主要介绍了Golang 1.16 中 Modules的主要变化更新,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2021-02-02
  • Golang汇编之控制流深入分析讲解

    Golang汇编之控制流深入分析讲解

    这篇文章主要介绍了Golang汇编之控制流,程序执行的流程主要有顺序、分支和循环几种执行流程,本节主要讨论如何将Go语言的控制流比较直观地转译为汇编程序,或者说如何以汇编思维来编写Go语言代码,感兴趣的同学可以参考下文
    2023-05-05
  • 一文告诉你大神是如何学习Go语言之make和new

    一文告诉你大神是如何学习Go语言之make和new

    当我们想要在 Go 语言中初始化一个结构时,其实会使用到两个完全不同的关键字,也就是 make 和 new,同时出现两个用于『初始化』的关键字对于初学者来说可能会感到非常困惑,不过它们两者有着却完全不同的作用,本文就和大家详细讲讲
    2023-02-02
  • GO语言异常处理机制panic和recover分析

    GO语言异常处理机制panic和recover分析

    这篇文章主要介绍了GO语言异常处理机制panic和recover,分析了捕获运行时发生错误的方法,是非常实用的技巧,需要的朋友可以参考下
    2014-12-12
  • Go简单实现协程方法

    Go简单实现协程方法

    本文主要介绍了Go简单实现协程的实现示例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2022-12-12
  • go语言 xorm框架 postgresql 的用法及详细注解

    go语言 xorm框架 postgresql 的用法及详细注解

    这篇文章主要介绍了go语言 xorm框架 postgresql 的用法及详细注解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2020-12-12
  • go goquery网页解析实现示例

    go goquery网页解析实现示例

    这篇文章主要为大家介绍了go goquery网页解析实现示例,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-08-08

最新评论