成功安装vscode中go的相关插件(详细教程)
让你成功安装vscode中go的相关插件
注意:该演⽰环境是windows环境,linux和mac环境操作思路⼀样
vscode中有很多go的相关插件,⾮常好⽤如下:
gocode
gopkgs
go-outline
go-symbols
guru
gorename
gomodifytags
goplay
impl
godef
goreturns
golint
gotests
dlv
但是由于各种原因,这些插件⽆法安装,甚⾄你之后发现也还是⽆法安装,加上最近被限制的这么严格,所以总结了如下⽅法,让你在不的情况下还能将这些插件安装成功,下图是我直接
通过vscode安装提⽰的错误:
貌似运⽓还不错,还安装成功了⼏个,但是⼤部分还是没有安装成功,下⾯是详细的安装⽇志:
Installing 14 tools at D:\go_project\bin
gocode
gopkgs
go-outline
go-symbols
guru
gorename
gomodifytags
goplay
impl
godef
goreturns
golint
gotests
dlv
Installing github/nsf/gocode SUCCEEDED
Installing github/uudashr/gopkgs/cmd/gopkgs SUCCEEDED
Installing github/ramya-rao-a/go-outline FAILED
Installing github/acroca/go-symbols FAILED
/x/tools/cmd/guru FAILED
/x/tools/cmd/gorename FAILED
Installing github/fatih/gomodifytags SUCCEEDED
Installing github/haya14busa/goplay/cmd/goplay SUCCEEDED
Installing github/josharian/impl FAILED
Installing github/rogpeppe/godef SUCCEEDED
Installing sourcegraph/sqs/goreturns FAILED
Installing github/golang/lint/golint FAILED
Installing github/cweill/gotests/... FAILED
Installing github/derekparker/delve/cmd/dlv SUCCEEDED
8 tools failed to install.
go-outline:
Error: Command failed: D:\Go\ get -u -v github/ramya-rao-a/go-outline
github/ramya-rao-a/go-outline (download)
Fetching /x/tools/go/buildutil?go-get=1
https fetch failed: Get /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 conne /x/tools/go/buildutil: unrecognized import path "/x/tools/go/buildutil" (https fetch: Get /x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party di github/ramya-rao-a/go-outline (download)
Fetching /x/tools/go/buildutil?go-get=1
https fetch failed: Get /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 conne /x/tools/go/buildutil: unrecognized import path "/x/tools/go/buildutil" (https fetch: Get /x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connecti
on attempt failed because the connected party di go-symbols:
Error: Command failed: D:\Go\ get -u -v github/acroca/go-symbols
github/acroca/go-symbols (download)
Fetching /x/tools/go/buildutil?go-get=1
https fetch failed: Get /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 bec /x/tools/go/buildutil: unrecognized import path "/x/tools/go/buildutil" (https fetch: Get /x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party di github/acroca/go-symbols (download)
Fetching /x/tools/go/buildutil?go-get=1
https fetch failed: Get /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 conne /x/tools/go/buildut
il: unrecognized import path "/x/tools/go/buildutil" (https fetch: Get /x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party di guru:
Error: Command failed: D:\Go\ get -u -/x/tools/cmd/guru
Fetching /x/tools/cmd/guru?go-get=1
https fetch failed: Get /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 connec /x/tools/cmd/guru: unrecognized import path "/x/tools/cmd/guru" (https fetch: Get /x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did no Fetching /x/tools/cmd/guru?go-get=1
https fetch failed: Get /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 connec /x/tools/cmd/gur
u: unrecognized import path "/x/tools/cmd/guru" (https fetch: Get /x/tools/cmd/guru?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did no gorename:
Error: Command failed: D:\Go\ get -u -/x/tools/cmd/gorename
Fetching /x/tools/cmd/gorename?go-get=1
https fetch failed: Get /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 c /x/tools/cmd/gorename: unrecognized import path "/x/tools/cmd/gorename" (https fetch: Get /x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the conne Fetching /x/tools/cmd/gorename?go-get=1
https fetch failed: Get /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 c /x/tools/cmd/gorename:
unrecognized import path "/x/tools/cmd/gorename" (https fetch: Get /x/tools/cmd/gorename?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the conne impl:
Error: Command failed: D:\Go\ get -u -v github/josharian/impl
github/josharian/impl (download)
Fetching /x/tools/imports?go-get=1
https fetch failed: Get /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 connecte /x/tools/imports: unrecognized import path "/x/tools/imports" (https fetch: Get /x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not prop github/josharian/impl (download)
Fetching /x/tools/imports?go-get=1
https fetch failed: Get /x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connect
ex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connecte /x/tools/imports: unrecognized import path "/x/tools/imports" (https fetch: Get /x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not prop goreturns:
Error: Command failed: D:\Go\ get -u -v sourcegraph/sqs/goreturns
Fetching sourcegraph/sqs/goreturns?go-get=1
Parsing meta tags from sourcegraph/sqs/goreturns?go-get=1 (status code 200)
get "sourcegraph/sqs/goreturns": found meta aImport{Prefix:"sourcegraph/sqs/goreturns", VCS:"git", RepoRoot:"github/sqs/goreturns"} at sourcegraph/sqs/goreturns?go-get=1
sourcegraph/sqs/goreturns (download)
github/sqs/goreturns (download)
Fetching /x/tools/imports?go-get=1
https fetch failed: Get /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 connecte /x/tools/imports: unrecognized import path "/x/tools/imports" (https fetch: Get /x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not prop Fetching sourcegraph/sqs/goreturns?go-get=1
Parsing meta tags from sourcegraph/sqs/goreturns?go-get=1 (status code 200)
get "sourcegraph/sqs/goreturns": found meta aImport{Prefix:"sourcegraph/sqs/goreturns", VCS:"git", RepoRoot:"github/sqs/goreturns"} at sourcegraph/sqs/goreturns?go-get=1
sourcegraph/sqs/goreturns (download)
github/sqs/goreturns (download)
Fetching /x/tools/imports?go-get=1
https fetch failed: Get /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 connecte /x/tools/imports: unrecognized import path "/x/tools/imports" (https fetch: Get /x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not prop golint:
Error: Command failed: D:\Go\ get -u -v github/golang/lint/golint
github/golang/lint (download)
Fetching /x/tools/go/gcexportdata?go-get=1
https fetch failed: Get /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 /x/tools/go/gcexportdata: unrecognized import path "/x/tools/go/gcexportdata" (https fetch: Get /x/tools/go/gcexportdata?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the co github/golang/lint (download)
Fetching /x/tools/go/gcexportdata?go-get=1
https fetch failed: Get /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 /x/tools/go/gcexportdata: unrecognized import path "/x/tools/go/gcexportdata" (https fetch: Get /x/tools/go/gcexportdata?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the co gotests:
Error: Command failed: D:\Go\ get -u -v github/cweill/gotests/...
github/cweill/gotests (download)
Fetching /x/tools/imports?go-get=1
https fetch failed: Get /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 connecte package github/cweill/gotests
/x/tools/imports: unrecognized import path "/x/tools/imports" (https fetch:
Get /x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not prop github/cweill/gotests (download)
Fetching /x/tools/imports?go-get=1
https fetch failed: Get /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 connecte package github/cweill/gotests
/x/tools/imports: unrecognized import path "/x/tools/imports" (https fetch: Get /x/tools/imports?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not prop 其实去src⽬录下看的话,是下载成功了,但是没有安装成功,并且我们也可以看出有⼏个是可以直接安装成功的
github/nsf/gocode
github/tpng/gopkgs
github/fatih/gomodifytags
github/haya14busa/goplay
github/rogpeppe/gode
github/derekparker/delve/cmd/dlv
解决⽅法
关于go开发⽬录的结构这⾥不做过多解释,之前已经说过了
进⾏如下命令进⾏⽬录切换:
cd %GOPATH%\src\github\golanggo语言安装教程
我这⾥的GOPATH是在D:\go_project
如果src⽬录下⾯没有github\golang请⾃⾏创建
完成⽬录切换后,开始下载插件包:
当下载完成后,你会发现%GOPATH%\src\github\golang多了⼀个tools⽬录
需要把tools⽬录下的所有⽂件拷贝到%GOPATH%\ \tools下,如果没有⾃⾏创建
当然如果你是windows环境,如果你当前是在%GOPATH%\ \tools
⽬录下,你可以直接使⽤如下命令进⾏拷贝:
xcopy /s /e %GOPATH%\src\github\golang\tools
关于这个命令的使⽤可以具体百度查看,如果对该命令不熟悉就⼿动拷贝,直接将你下载的tools⽬录下的所有⽂件拷贝到%GOPATH%\ \tools⽬录下
经过多次测试,插件中有⼏个其实不⽤或其他⽅法就可以安装成功:
github/nsf/gocode
github/uudashr/gopkgs/cmd/gopkgs
github/fatih/gomodifytags
github/haya14busa/goplay/cmd/goplay
github/derekparker/delve/cmd/dlv
下⾯安装⽆法安装的插件
开始安装:
切换到GOPATH⽬录下,执⾏相关的go install 命令
go install github/ramya-rao-a/go-outline
go install github/acroca/go-symbols
go /x/tools/cmd/guru
go /x/tools/cmd/gorename
go install github/josharian/impl
go install github/rogpeppe/godef
go install github/sqs/goreturns
go install github/golang/lint/golint
go install github/cweill/gotests/gotests
这样vscode下go开发需要安装的插件都已经安装成功
总结
到此这篇关于成功安装vscode中go的相关插件的详细教程的⽂章就介绍到这了,更多相关vscode安装go插件内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。