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语言中锁特性和实现

    一文带你了解Go语言中锁特性和实现

    Go语言中的sync包主要提供的对并发操作的支持,标志性的工具有cond(条件变量) once (原子性) 还有 锁,本文会主要向大家介绍Go语言中锁的特性和实现,感兴趣的可以了解下
    2024-03-03
  • go语言程序cpu过高问题排查的方法详解

    go语言程序cpu过高问题排查的方法详解

    使用golang进行复杂的组合运算,导致CPU占用率非常高,下面这篇文章主要给大家介绍了关于go语言程序cpu过高问题排查的相关资料,文中通过实例代码介绍的非常详细,需要的朋友可以参考下
    2023-04-04
  • 一文搞懂如何实现Go 超时控制

    一文搞懂如何实现Go 超时控制

    这篇文章主要介绍了一文搞懂如何实现Go 超时控制,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2021-03-03
  • 浅谈Go语言的高效编码细节

    浅谈Go语言的高效编码细节

    这篇文章主要介绍了浅谈Go语言的高效编码细节,我们都知道golang是天生的高并发,高效的编译型语言,可我们也都可知道,工具再好,用法不对,全都白费,我们来举2个常用路径来感受一下
    2023-01-01
  • Go语言数据类型详细介绍

    Go语言数据类型详细介绍

    这篇文章主要介绍了Go语言数据类型详细介绍,Go语言数据类型包含基础类型和复合类型两大类,下文关于这两类型的相关介绍,需要的小伙伴可以参考一下
    2022-03-03
  • golang 整合antlr语法校验解析

    golang 整合antlr语法校验解析

    Antlr是一个语法分析器,本身是用java实现的,然是Runtime的库也支持Golang、Java、Python等,本文给大家讲解使用golang整合antlr进行语法解析,感兴趣的朋友一起看看吧
    2023-02-02
  • golang 对私有函数进行单元测试的实例

    golang 对私有函数进行单元测试的实例

    这篇文章主要介绍了golang 对私有函数进行单元测试的实例,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2021-05-05
  • Go语言实现控制台输入&生成随机数详解

    Go语言实现控制台输入&生成随机数详解

    这篇文章主要介绍了Go语言如何实现控制台输入&生成随机数,文中通过示例代码介绍的非常详细,对大家的学习有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2022-05-05
  • golang中的三个点 ''...''的用法示例详解

    golang中的三个点 ''...''的用法示例详解

    这篇文章主要介绍了golang中的三个点 '...' 的用法示例详解,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2020-11-11
  • go get 和 go install 对比介绍

    go get 和 go install 对比介绍

    go install和go get都是Go语言的工具命令,但它们之间有一些区别。go get:用于从远程代码存储库(如 GitHub)中下载或更新Go代码包。go install:用于编译并安装 Go 代码包,本文go get和go install对比介绍的非常详细,需要的朋友可以参考一下
    2023-04-04

最新评论