go 和 vscode 的安装、环境变量的配置,请参考前一篇文章 https://mp.csdn.net/postedit/100578467
在 Ubuntu 下 vscode 中安装 golang 插件工具包时,提示好几个依赖工具包安装失败,失败的原因就不说了,都懂的。
下面讲如何解决依赖工具包安装失败的问题。
以下为手动安装依赖工具包的步骤:
1、在 %GOPATH%/src/ 目录下,创建路径 golang.org/x,(ps:就是在 src 文件夹下建一个名为 goalng.org 的文件夹,然后在golang.org 文件下建一个名为x的文件夹)
2、打开终端,进入到 %GOPATH%/src/golang.org/x 下(就是用 cd 命令进入),执行以下命令下载需要安装工具包的源码
git clone https://github.com/golang/tools.git
clone 完成后,在 x 文件夹下会生成一个 tools 文件夹,至此,工具包所需要的源码已经准备好了。
3、下面,cd 进入到 %GOPATH% 下,执行以下命令:
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/rogpeppe/godef
go install github.com/sqs/goreturns
go install github.com/cweill/gotests/gotests
4、对于 golint 这种包,只能单独手动 clone 后再 go install,具体做法为:
打开终端,cd 进入%GOPATH%/src/golang.org/x 后,执行
git clone https://github.com/golang/lint
下载完成 golint 需要的源码后,进入到 %GOPATH%下,执行
go install golang.org/x/lint/golint
至此,golint 就安装完成了。
5、下面,附上所有工具包的源码地址,只需要手动 git clone 后,再执行 go install 安装就行(需要注意路径的切换!!!)
1 gocode https://github.com/mdempsky/gocode
2 gopkgs https://github.com/uudashr/gopkgs
3 go-outline https://github.com/ramya-rao-a/go-outline
4 go-symbols https://github.com/acroca/go-symbols
5 guru https://github.com/golang/tools
6 gorename https://github.com/golang/tools
7 dlv https://github.com/go-delve/delve
8 gocode-gomod https://github.com/stamblerre/gocode
9 godef https://github.com/rogpeppe/godef
10 goreturns https://github.com/sqs/goreturns
11 golint https://github.com/golang/lint
12 gotests https://github.com/cweill/gotests
13 gomodifytags https://github.com/fatih/gomodifytags
14 impl https://github.com/josharian/impl
15 fillstruct https://github.com/davidrjenni/reftools
16 goplay https://github.com/haya14busa/goplay
17 godoctor https://github.com/godoctor/godoctor
最后
以上就是整齐眼神最近收集整理的关于ubuntu 下配置 golang + vscode开发环境,解决 golang 插件依赖安装失败问题的全部内容,更多相关ubuntu内容请搜索靠谱客的其他文章。
发表评论 取消回复