博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
让你成功安装vscode中go的相关插件
阅读量:6858 次
发布时间:2019-06-26

本文共 16309 字,大约阅读时间需要 54 分钟。

注意:该演示环境是windows环境,linux和mac环境操作思路一样

vscode中有很多go的相关插件,非常好用如下:

gocode
gopkgs
go-outline
go-symbols
guru
gorename
gomodifytags
goplay
impl
godef
goreturns
golint
gotests
dlv

但是由于各种原因,这些插件无法安装,甚至你FQ之后发现也还是无法安装,加上最近FQ被限制的这么严格,所以总结了如下方法,让你在不FQ的情况下还能将这些插件安装成功,下图是我直接通过vscode安装提示的错误:

貌似运气还不错,还安装成功了几个,但是大部分还是没有安装成功,下面是vscode详细的安装日志:

Installing 14 tools at D:\go_project\bin  gocode  gopkgs  go-outline  go-symbols  guru  gorename  gomodifytags  goplay  impl  godef  goreturns  golint  gotests  dlvInstalling github.com/nsf/gocode SUCCEEDEDInstalling github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDEDInstalling github.com/ramya-rao-a/go-outline FAILEDInstalling github.com/acroca/go-symbols FAILEDInstalling golang.org/x/tools/cmd/guru FAILEDInstalling golang.org/x/tools/cmd/gorename FAILEDInstalling github.com/fatih/gomodifytags SUCCEEDEDInstalling github.com/haya14busa/goplay/cmd/goplay SUCCEEDEDInstalling github.com/josharian/impl FAILEDInstalling github.com/rogpeppe/godef SUCCEEDEDInstalling sourcegraph.com/sqs/goreturns FAILEDInstalling github.com/golang/lint/golint FAILEDInstalling github.com/cweill/gotests/... FAILEDInstalling github.com/derekparker/delve/cmd/dlv SUCCEEDED8 tools failed to install.go-outline:Error: Command failed: D:\Go\bin\go.exe get -u -v github.com/ramya-rao-a/go-outlinegithub.com/ramya-rao-a/go-outline (download)Fetching https://golang.org/x/tools/go/buildutil?go-get=1https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/go/buildutil: unrecognized import path "golang.org/x/tools/go/buildutil" (https fetch: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)github.com/ramya-rao-a/go-outline (download)Fetching https://golang.org/x/tools/go/buildutil?go-get=1https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/go/buildutil: unrecognized import path "golang.org/x/tools/go/buildutil" (https fetch: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)go-symbols:Error: Command failed: D:\Go\bin\go.exe get -u -v github.com/acroca/go-symbolsgithub.com/acroca/go-symbols (download)Fetching https://golang.org/x/tools/go/buildutil?go-get=1https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/go/buildutil: unrecognized import path "golang.org/x/tools/go/buildutil" (https fetch: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)github.com/acroca/go-symbols (download)Fetching https://golang.org/x/tools/go/buildutil?go-get=1https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/go/buildutil: unrecognized import path "golang.org/x/tools/go/buildutil" (https fetch: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)guru:Error: Command failed: D:\Go\bin\go.exe get -u -v golang.org/x/tools/cmd/guruFetching https://golang.org/x/tools/cmd/guru?go-get=1https fetch failed: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/cmd/guru: unrecognized import path "golang.org/x/tools/cmd/guru" (https fetch: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)Fetching https://golang.org/x/tools/cmd/guru?go-get=1https fetch failed: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/cmd/guru: unrecognized import path "golang.org/x/tools/cmd/guru" (https fetch: Get https://golang.org/x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)gorename:Error: Command failed: D:\Go\bin\go.exe get -u -v golang.org/x/tools/cmd/gorenameFetching https://golang.org/x/tools/cmd/gorename?go-get=1https fetch failed: Get https://golang.org/x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/cmd/gorename: unrecognized import path "golang.org/x/tools/cmd/gorename" (https fetch: Get https://golang.org/x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)Fetching https://golang.org/x/tools/cmd/gorename?go-get=1https fetch failed: Get https://golang.org/x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/cmd/gorename: unrecognized import path "golang.org/x/tools/cmd/gorename" (https fetch: Get https://golang.org/x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)impl:Error: Command failed: D:\Go\bin\go.exe get -u -v github.com/josharian/implgithub.com/josharian/impl (download)Fetching https://golang.org/x/tools/imports?go-get=1https fetch failed: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/imports: unrecognized import path "golang.org/x/tools/imports" (https fetch: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)github.com/josharian/impl (download)Fetching https://golang.org/x/tools/imports?go-get=1https fetch failed: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/imports: unrecognized import path "golang.org/x/tools/imports" (https fetch: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)goreturns:Error: Command failed: D:\Go\bin\go.exe get -u -v sourcegraph.com/sqs/goreturnsFetching https://sourcegraph.com/sqs/goreturns?go-get=1Parsing meta tags from https://sourcegraph.com/sqs/goreturns?go-get=1 (status code 200)get "sourcegraph.com/sqs/goreturns": found meta tag get.metaImport{Prefix:"sourcegraph.com/sqs/goreturns", VCS:"git", RepoRoot:"https://github.com/sqs/goreturns"} at https://sourcegraph.com/sqs/goreturns?go-get=1sourcegraph.com/sqs/goreturns (download)github.com/sqs/goreturns (download)Fetching https://golang.org/x/tools/imports?go-get=1https fetch failed: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/imports: unrecognized import path "golang.org/x/tools/imports" (https fetch: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)Fetching https://sourcegraph.com/sqs/goreturns?go-get=1Parsing meta tags from https://sourcegraph.com/sqs/goreturns?go-get=1 (status code 200)get "sourcegraph.com/sqs/goreturns": found meta tag get.metaImport{Prefix:"sourcegraph.com/sqs/goreturns", VCS:"git", RepoRoot:"https://github.com/sqs/goreturns"} at https://sourcegraph.com/sqs/goreturns?go-get=1sourcegraph.com/sqs/goreturns (download)github.com/sqs/goreturns (download)Fetching https://golang.org/x/tools/imports?go-get=1https fetch failed: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/imports: unrecognized import path "golang.org/x/tools/imports" (https fetch: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)golint:Error: Command failed: D:\Go\bin\go.exe get -u -v github.com/golang/lint/golintgithub.com/golang/lint (download)Fetching https://golang.org/x/tools/go/gcexportdata?go-get=1https fetch failed: Get https://golang.org/x/tools/go/gcexportdata?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/go/gcexportdata: unrecognized import path "golang.org/x/tools/go/gcexportdata" (https fetch: Get https://golang.org/x/tools/go/gcexportdata?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)github.com/golang/lint (download)Fetching https://golang.org/x/tools/go/gcexportdata?go-get=1https fetch failed: Get https://golang.org/x/tools/go/gcexportdata?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package golang.org/x/tools/go/gcexportdata: unrecognized import path "golang.org/x/tools/go/gcexportdata" (https fetch: Get https://golang.org/x/tools/go/gcexportdata?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)gotests:Error: Command failed: D:\Go\bin\go.exe get -u -v github.com/cweill/gotests/...github.com/cweill/gotests (download)Fetching https://golang.org/x/tools/imports?go-get=1https fetch failed: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package github.com/cweill/gotests    imports golang.org/x/tools/imports: unrecognized import path "golang.org/x/tools/imports" (https fetch: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)github.com/cweill/gotests (download)Fetching https://golang.org/x/tools/imports?go-get=1https fetch failed: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.package github.com/cweill/gotests    imports golang.org/x/tools/imports: unrecognized import path "golang.org/x/tools/imports" (https fetch: Get https://golang.org/x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)

  

其实去src目录下看的话,是下载成功了,但是没有安装成功,并且我们也可以看出有几个是可以直接安装成功的

github.com/nsf/gocode
github.com/tpng/gopkgs
github.com/fatih/gomodifytags
github.com/haya14busa/goplay
github.com/rogpeppe/gode
github.com/derekparker/delve/cmd/dlv

解决方法

关于go开发目录的结构这里不做过多解释,之前已经说过了

进行如下命令进行目录切换:

cd %GOPATH%\src\github.com\golang
我这里的GOPATH是在D:\go_project
如果src目录下面没有github.com\golang请自行创建

完成目录切换后,开始下载插件包:

git clone  tools

当下载完成后,你会发现%GOPATH%\src\github.com\golang多了一个tools目录

需要把tools目录下的所有文件拷贝到%GOPATH%\src\golang.org\x\tools下,如果没有自行创建
当然如果你是windows环境,如果你当前是在%GOPATH%\src\golang.org\x\tools
目录下,你可以直接使用如下命令进行拷贝:
xcopy /s /e %GOPATH%\src\github.com\golang\tools
关于这个命令的使用可以具体百度查看,如果对该命令不熟悉就手动拷贝,直接将你下载的tools目录下的所有文件拷贝到%GOPATH%\src\golang.org\x\tools目录下

经过多次测试,插件中有几个其实不用FQ或其他方法就可以安装成功:

github.com/nsf/gocode
github.com/uudashr/gopkgs/cmd/gopkgs
github.com/fatih/gomodifytags
github.com/haya14busa/goplay/cmd/goplay
github.com/derekparker/delve/cmd/dlv

下面安装无法安装的插件

开始安装:
切换到GOPATH目录下,执行相关的go install 命令 

go install github.com/ramya-rao-a/go-outline

go install github.com/acroca/go-symbols 

go install golang.org/x/tools/cmd/guru 

go install golang.org/x/tools/cmd/gorename 

go install github.com/josharian/impl 

go install github.com/rogpeppe/godef 

go install github.com/sqs/goreturns 

go install github.com/golang/lint/golint 

go install github.com/cweill/gotests/gotests

这样vscode下go开发需要安装的插件都已经安装成功

 

所有的努力都值得期许,每一份梦想都应该灌溉!

转载地址:http://tdiyl.baihongyu.com/

你可能感兴趣的文章
涨姿势,图文带你了解 8 大排序算法
查看>>
Java基础知识的全面巩固_note1(附各种demo code)
查看>>
DataWorks2.0的“业务流程”与1.0的“工作流”的对比
查看>>
基于Kubernetes的容器云在万达的落地
查看>>
阿里联合ICA联盟发布IoT系列标准,智能门锁标准首批授权测试机构名单出炉
查看>>
Fastify 2.2.0 和 1.14.5 发布,极速 Node.js Web 框架
查看>>
vim设置一键执行python代码
查看>>
普通程序员该如何进阶为全栈工程师?
查看>>
WebStorm 开发配置
查看>>
Android动画相关(一)
查看>>
Spring @RequestBody与@ResponseBody注解
查看>>
python之turtle实现‘开花’和签名
查看>>
报表集成那点事
查看>>
《深入理解mybatis原理》 Mybatis数据源与连接池
查看>>
Spring小知识
查看>>
Oracle 12c连接时报错ORA-28040问题解决方法
查看>>
入门设计模式之状态模式
查看>>
Python机器学习(二):线性回归算法
查看>>
SQL Server中有关约束(constraint)的一些细节
查看>>
MapReduce高级特性
查看>>