VS Code安装go插件失败原因分析以及解决方案
作者:一越王超 发布时间:2024-04-26 17:24:08
问题背景
VSCode是我们开发go程序的常用工具,但是安装VSCode成功后,创建一个.go文件会有如下提示:
这个是vscode提示你需要安装go插件,但是当你点击install all进行安装时,发现会安装失败。
Installing 8 tools at D:\pragrams\go\bin
gocode
gopkgs
go-outline
go-symbols
dlv
godef
goreturns
golint
Installing github.com/mdempsky/gocode FAILED
Installing github.com/uudashr/gopkgs/cmd/gopkgs FAILED
Installing github.com/ramya-rao-a/go-outline FAILED
Installing github.com/acroca/go-symbols FAILED
Installing github.com/derekparker/delve/cmd/dlv FAILED
Installing github.com/rogpeppe/godef FAILED
Installing github.com/sqs/goreturns FAILED
Installing golang.org/x/lint/golint FAILED
8 tools failed to install.
gocode:
Error: Command failed: D:\install\go\bin\go.exe get -u -v github.com/mdempsky/gocode
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/mdempsky/gocode: exec: "git": executable file not found in %PATH%
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/mdempsky/gocode: exec: "git": executable file not found in %PATH%
gopkgs:
Error: Command failed: D:\install\go\bin\go.exe get -u -v github.com/uudashr/gopkgs/cmd/gopkgs
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/uudashr/gopkgs/cmd/gopkgs: exec: "git": executable file not found in %PATH%
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/uudashr/gopkgs/cmd/gopkgs: exec: "git": executable file not found in %PATH%
go-outline:
Error: Command failed: D:\install\go\bin\go.exe get -u -v github.com/ramya-rao-a/go-outline
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/ramya-rao-a/go-outline: exec: "git": executable file not found in %PATH%
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/ramya-rao-a/go-outline: exec: "git": executable file not found in %PATH%
go-symbols:
Error: Command failed: D:\install\go\bin\go.exe get -u -v github.com/acroca/go-symbols
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/acroca/go-symbols: exec: "git": executable file not found in %PATH%
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/acroca/go-symbols: exec: "git": executable file not found in %PATH%
dlv:
Error: Command failed: D:\install\go\bin\go.exe get -u -v github.com/derekparker/delve/cmd/dlv
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/derekparker/delve/cmd/dlv: exec: "git": executable file not found in %PATH%
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/derekparker/delve/cmd/dlv: exec: "git": executable file not found in %PATH%
godef:
Error: Command failed: D:\install\go\bin\go.exe get -u -v github.com/rogpeppe/godef
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/rogpeppe/godef: exec: "git": executable file not found in %PATH%
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/rogpeppe/godef: exec: "git": executable file not found in %PATH%
goreturns:
Error: Command failed: D:\install\go\bin\go.exe get -u -v github.com/sqs/goreturns
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/sqs/goreturns: exec: "git": executable file not found in %PATH%
go: missing Git command. See https://golang.org/s/gogetcmd
package github.com/sqs/goreturns: exec: "git": executable file not found in %PATH%
golint:
Error: Command failed: D:\install\go\bin\go.exe get -u -v golang.org/x/lint/golint
go: missing Git command. See https://golang.org/s/gogetcmd
package golang.org/x/lint/golint: exec: "git": executable file not found in %PATH%
go: missing Git command. See https://golang.org/s/gogetcmd
package golang.org/x/lint/golint: exec: "git": executable file not found in %PATH%
问题原因
在安装go插件时,会自动更新很多依赖库文件,都是从Github更新下来,但是因为Github的文件中,多有应用go官网中的文件,因为一些网络国内无法访问,网络缘故,不能直接下载,导致安装失败。
解决方案
方案1:快速方案
核心是配置国内下载源,我们需要修改如下两个go的环境配置:
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn
配置好两个变量后,重新打开VSCode,点击右下方的install all重新安装,
或者,在vscode中使用Ctrl+Shift+P,输入>go:install,下面会自动搜索相关命令,我们选择Go:Install/Update Tools这个命令,选中所有插件,点击确定进行安装。
问题成功解决:
方案2:环境变量中配置
Windows在电脑 -> 系统 -> 高级系统设置 -> 用户环境中分别新建GO111MODULE和GOPROXY两个用户变量,其值如下图所示:
GO111MODULE=on
GOPROXY=https://goproxy.cn,direct
或者也可以使用阿里源代理如下:
GO111MODULE=on
GOPROXY=https://mirrors.aliyun.com/goproxy/
配置好之后,使用Windows + R调出终端,输入cmd,通过go env命令查看go的环境变量配置是否设置成功。
方案3:vscode中配置
vscode编辑器的设置在:文件 -> 首选项 -> 设置 -> 用户 -> 应用程序 -> 代理服务器路径下,如下图所示:
来源:https://blog.csdn.net/qq_36564503/article/details/124509832
猜你喜欢
- PyQtGraph是纯Python的,只是它底层调用的是PyQt,也就是Qt的Python封装,底层用C/C++语言开发的库,它是在PyQt
- 本次爬虫思路最最重要的是分析信息接口!!!1. 获取url2. 通过请求拿到响应3. 处理反爬4. 提取信息5. 保存内容本次操练网页htt
- 这篇文章主要介绍了python中的引用和拷贝实例解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友
- Python 是一种流行的编程语言,也是数据科学社区中最受欢迎的语言。与其他流行编程语言相比,Python 的主要缺点是它的动态特性和多功能
- Sun公司和Zmanda在3月18号声称他们正在一起合作,为MySQL Enterprise用户交付一种全面、全局数据备份与恢复解决方案。现
- 内容摘要:在像网站首页这样的资源比较集中的页面中,那些栏目最经常被用户点击?居左居右对广告的点击率的影响是什么?“一切用数字说话”:以上问题
- 一.Numpy库1.什么是numpy?numpy是python进行科学计算的一个基础软件包,他是一个python库,提供多维数组
- python的版本经过了python2.x和python3.x等版本,无论哪种版本,关于python爬虫相关的知识是融会贯通的,脚本之家关于
- python五子棋原创算法,供大家参考,具体内容如下我们都见过五子棋,但是在我看来五子棋单机游戏中,逻辑赢法很重要,经常用到的算法是五子连珠
- 本文实例讲述了Python wxpython模块响应鼠标拖动事件操作。分享给大家供大家参考,具体如下:wxpython鼠标拖动事件小案例:#
- 本文实例为大家分享了wxPython整点报时的具体代码,供大家参考,具体内容如下# C盘要有个wav文件,内含报时音频import wx &
- 每天面对成堆的发票,无论是发票还是承兑单据,抑或是其他各类公司数据要从照片、PDF等不同格式的内容中提取,我们都有必要进行快速办公的能力提升
- 找到detect.py,在大概113行,找到plot_one_box &
- 人丑就要多读书,颜值不够知识来凑,至少你可以用书籍来武装你的大脑,拯救你的人生。TIOBE编程语言排行榜前20的语言入门书籍推荐
- 设计师不等于美工设计无所不在,但大多数企业不知道如何使用它。现代设计进入中国大概是二十多年的时间,而在国外,尤其在美国在欧洲,大概有一百年的
- 在使用flask部署Keras,tensorflow等框架时候,经常出现FailedPreconditionError: Attemptin
- 1. 说明本篇主要针对在Ubuntu系统中,matplotlib显示不了中文的问题,尤其是在无法安装系统
- 介绍还记得你在小学时学习如何加减数字吗?现在,你也可以对图像做同样的事情!输入图像可以进行算术运算,例如加法、减法和按位运算(AND、OR、
- 可以查看: 代码如下:OPEN SYMMETRIC KEY 命令关于 对称密钥加密使用证书解密 CREATE MASTER KEY ENC
- 今天发现 WordPress 连接不上数据库,登录 window server 服务器查看,所有服务均运行正常。使用 root 账号登录 m