当前位置:   article > 正文

解决:vscode中go插件中的工具包无法安装成功的问题_this extension is disabled in this workspace becau

this extension is disabled in this workspace because it is defined to run in

工欲善其事,必先利其器

坑啊!我可以google,但就是无法使用vscode在安装时去下载"golang.org/x/tools"下的东西,全部都是这个报错,导致很多go插件提供的骚功能无法使用,也对不起vs这位宇宙第一ide的兄弟vscode,没办法只能开启手动下载安装模式。下面是vs自动安装的输出,有的成功有的失败,失败的原因都一样,成功的可以庆祝一下。

Installing 14 tools at F:\Softs\GoLang\repository
  gocode
  gopkgs
  go-outline
  go-symbols
  guru
  gorename
  gomodifytags
  goplay
  impl
  godef
  goreturns
  golint
  gotests
  dlv

Installing github.com/nsf/gocode FAILED
Installing github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDED
Installing github.com/ramya-rao-a/go-outline FAILED
Installing github.com/acroca/go-symbols FAILED
Installing golang.org/x/tools/cmd/guru FAILED
Installing golang.org/x/tools/cmd/gorename FAILED
Installing github.com/fatih/gomodifytags FAILED
Installing github.com/haya14busa/goplay/cmd/goplay SUCCEEDED
Installing github.com/josharian/impl FAILED
Installing github.com/rogpeppe/godef SUCCEEDED
Installing sourcegraph.com/sqs/goreturns FAILED
Installing github.com/golang/lint/golint FAILED
Installing github.com/cweill/gotests/... FAILED
Installing github.com/derekparker/delve/cmd/dlv SUCCEEDED
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

解决:
1、切换到 %GOPATH%/src/github.com目录下,我的%GOPATH%是 F:\Softs\GoLang\repository,如果 github.com目录下面没有golang请自行创建
2、完成目录切换后,开始下载插件包: git clone https://github.com/golang/tools.git tools
3、将下载的tools目录文件夹拷贝到%GOPATH%\src\golang.org\x\下,如果没有相关路径自行创建
4、我们将上面无法安装成功的包,手动安装,由于每个人可能安装成功的不一样,可以全部执行,将目录切换到%GOPATH%下执行下面代码

go install github.com/nsf/gocode
go install github.com/uudashr/gopkgs/cmd/gopkgs 
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/fatih/gomodifytags 
go install github.com/haya14busa/goplay/cmd/goplay 
go install github.com/josharian/impl 
go install github.com/rogpeppe/godef 
go install sourcegraph.com/sqs/goreturns 
go install github.com/golang/lint/golint 
go install github.com/cweill/gotests/... 
go install github.com/derekparker/delve/cmd/dlv
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

在这里基本已经可以结束了,但是由于有些包在vscode自动安装的时候并没有下载成功,会出现

can’t load package: package github.com/josharian/impl: cannot find package “github.com/josharian/impl” in any of:
  • 1

等类似错误,我们只需要在%GOPATH%/src/github.com目录下执行git clone https://github.com/josharian/impl,就是提示哪个无法找到就执行就可以了,然后再切换到%GOPATH%目录下继续执行即可。
我目前使用的是go1.11版本,vscode版本是1.31.1,亲测没问题,有问题欢迎留言。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/177916
推荐阅读
相关标签
  

闽ICP备14008679号