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插件失败内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • Golang语言如何避免空指针引发的panic详解

    Golang语言如何避免空指针引发的panic详解

    简单地说go语言的指针类型和C/C++的指针类型用法是一样的,除了出去安全性的考虑,go语言增加了一些限制,这篇文章主要给大家介绍了关于Golang语言如何避免空指针引发panic的相关资料,需要的朋友可以参考下
    2022-01-01
  • Golang使用elastic库来实现前后端模糊搜索功能

    Golang使用elastic库来实现前后端模糊搜索功能

    这篇文章主要为大家详细介绍了如何使用Golang和TypeScript的elastic库来实现前端和后端交互的模糊搜索功能,文中的示例代码讲解详细,感兴趣的小伙伴可以了解下
    2025-11-11
  • Go语言中的数据格式(json、xml 、msgpack、protobuf)使用总结

    Go语言中的数据格式(json、xml 、msgpack、protobuf)使用总结

    在分布式的系统中,因为涉及到数据的传输,所以一定会进行数据的交换,此时就要定义数据交换的格式,例如二进制、Json、Xml等等。本文总结了Go语言中的数据格式,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2022-07-07
  • Go语言使用defer+recover解决panic导致程序崩溃的问题

    Go语言使用defer+recover解决panic导致程序崩溃的问题

    如果协程出现了panic,就会造成程序的崩溃,这时可以在goroutine中使用recover来捕获panic,进行处理,本文就详细的介绍一下,感兴趣的可以了解一下
    2021-09-09
  • 学习GO编程必备知识汇总

    学习GO编程必备知识汇总

    这篇文章主要介绍了学习GO编程必备知识汇总的相关资料,需要的朋友可以参考下
    2016-07-07
  • Go语言中的格式化输出占位符的用法详解

    Go语言中的格式化输出占位符的用法详解

    在 Go 语言中,格式化输出是一个非常常用的功能,特别是在处理字符串、数字和其他数据类型时,本文将详细介绍 Go 语言中常用的格式化占位符及其用法,希望对大家有所帮助
    2024-10-10
  • vscode插件设置之Golang开发环境配置全过程

    vscode插件设置之Golang开发环境配置全过程

    go语言开发选择vscode作为IDE工具也是一个不错的选择,下面这篇文章主要给大家介绍了关于vscode插件设置之Golang开发环境配置的相关资料,文中通过图文介绍的非常详细,需要的朋友可以参考下
    2022-12-12
  • 三种Golang数组拷贝的实现方式与性能分析

    三种Golang数组拷贝的实现方式与性能分析

    在 Golang 中,有多种方式可以进行数组的拷贝,本文将对其中的三种方式进行性能分析,并比较它们的优缺点,感兴趣的小伙伴可以跟随小编一起学习一下
    2023-06-06
  • Golang实现AES对称加密的过程详解

    Golang实现AES对称加密的过程详解

    AES是一个对称密码,旨在取代DES成为广泛使用的标准,本文给大家分享Golang实现AES对称加密的过程,本文附有Golang实现AES加密ECB模式的源码,感兴趣的朋友跟随小编一起学习下吧
    2021-05-05
  • Go异常处理、泛型和文件操作实例代码

    Go异常处理、泛型和文件操作实例代码

    Go语言的异常处理机制与传统的面向对象语言(如 Java、C#)所使用的 try-catch 结构有所不同,它采用了自己独特的设计理念和方法,这篇文章主要介绍了Go异常处理、泛型和文件操作的相关资料,需要的朋友可以参考下
    2025-12-12

最新评论