go 安装github包_vscode安装go所有插件

当VSCode自动安装Go插件失败时,可以通过手动从GitHub下载并安装。本文详细介绍了如何手动下载和安装gopkgs、go-outline、go-symbols等Go插件,包括其依赖包,并提供了相应的git clone命令和go install命令。
摘要由CSDN通过智能技术生成
1.vscode安装go所有插件

vscode版本:1.51.0

go版本:version go1.15.2 windows/amd64

git客户端版本:Git-2.29.2.2-64-bit

2.使用vscode自动安装

1)需要提前安装go、vscode、git客户端,配置git环境,配置go环境,GOPATH这个环境变量 对下面的安装很重要

2)根据go的工程目录要求(go比较奇怪,对工程目录有限制),如果不太清楚的小伙伴,可以参考这个博客https://www.cnblogs.com/zsy/p/5262632.html

3)组织好之后,用vscode 加载GOPATH目录,在src目录下面建立一个测试用的文件,命名为.go的扩展名,vscode就会自动的弹出让安装go的插件,前提是vscode安装了go的扩展f2297468e33f5b0865a8aea2d6b08091.png

长这个样子,通过在这个扩展的地方搜索go插件就可以安装

4)自动弹出来的go插件安装界面长下面这个样子,点那个Install All 就行6d1b98d19896389427cc53bf08ca2d86.png

他需要安装下面这些插件:

gopkgs

go-outline

go-symbols

guru

gorename

gotests

gomodifytags

impl

fillstruct

goplay

godoctor

dlv

gocode-gomod

godef

goreturns

但是我的安装全部失败:

49b3b3ab360bfdee2eb8c50f17b0948d.png

不要慌!!!!!!!!!!!!!这点小问题还是难不倒国人的,请往下看

3.问题解决办法

3.1需要手动从github上面将包下载下来

        在src目录下面建立两个目录

– src
|–golang.org
---- |–x
|–github.com

有些包是需要放到github.com,有另外一部分是需要放到golang.org\x这个文件夹中的

gopkgs包

在src的gitbub.com文件夹下,使用cmd命令窗口输入,一定要按照这个文件目录生成,要不然没有办法安装,

git clone https://github.com/uudashr/gopkgs.git uudashr/gopkgs

这个包的安装需要另外两个辅助包:

git clone https://github.com/pkg/errors pkg/errors

git clone https://github.com/karrick/godirwalk.git karrick/godirwalk

下载完上面的两个辅助包,就可以进行安装了

使用cmd命令行窗口(在任意目录下),输入下面的命令就可以安装了:

go install github.com/uudashr/gopkgs/v2/cmd/gopkgs

安装完成之后,在src同级的bin目录下会生成gocode.exe

46b9419730287c30f2e98461ddd51bfa.png

go-outline包

在github.com目录下面,使用下面的命令下载包:

git clone https://github.com/ramya-rao-a/go-outline.git ramya-rao-a/go-outline

安装:(在任意目录下面,下面都一样)

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

go-symbols包

下载:在github.com目录下面

git clone https://github.com/acroca/go-symbols.git acroca/go-symbols

安装:

go install github.com/acroca/go-symbols

安装完成之后,在bin下会生成go-symbols.exe

ccb51e438f7b77893ff21f7354d456e9.png

guru、gorename包

这两个包在tools这个大包中,我们把这个大包下载下来,这个比较大,下载比较慢

下载:在golang.org/x目录下面,没有x这个目录新建一个,这个就是字母x,不是指代

git clone https://github.com/golang/tools.git tools

这个的安装也需要辅助包:

git clone https://github.com/golang/xerrors.git xerrors (在golang.org/x目录下)

git clone https://github.com/golang/mod.git mod(在golang.org/x目录下)

安装:

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

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

在bin目录下面会出现guru.exe、gorename.exe

5b7072e98569711e199b5dc676f0a00c.png

gotests包

下载:在github.com目录下面,这个有点慢

git clone https://github.com/cweill/gotests.git cweill/gotests

安装:

go install github.com/cweill/gotests

gomodifytags包

下载:在github.com目录下面

git clone https://github.com/fatih/gomodifytags.git fatih/gomodifytags

这个也需要辅助包:在github.com目录下面

git clone https://github.com/fatih/structtag.git fatih/structtag

git clone https://github.com/fatih/camelcase.git fatih/camelcase

安装:

go install github.com/fatih/gomodifytags

在bin下会出现一个gomodifytags.exe

9d9db20403854a137adae6e62ccb45a9.png

impl包

下载:在github.com目录下面

git clone https://github.com/josharian/impl.git josharian/impl

安装:

go install github.com/josharian/impl

在bin下会出现impl.exe

cb01e5848ff401305e6b1e9c5eff4be0.png

fillstruct包

下载:在github.com目录下面,这个有点慢

git clone https://github.com/davidrjenni/reftools.git davidrjenni/reftools

安装:

go install github.com/davidrjenni/reftools/cmd/fillstruct

在bin下会出现fillstruct.exe

goplay包

下载:在github.com目录下面

git clone https://github.com/haya14busa/goplay haya14busa/goplay

这个需要辅助包:在github.com目录下面

git clone https://github.com/skratchdot/open-golang.git skratchdot/open-golang

安装:

go install github.com/haya14busa/goplay/cmd/goplay

在bin目录下面会出现goplay.exe

cb01e5848ff401305e6b1e9c5eff4be0.png

godoctor包

下载:在github.com目录下面,这个有点慢

git clone https://github.com/godoctor/godoctor.git godoctor/godoctor

安装:

go install github.com/godoctor/godoctor

在bin目录下会出现godoctor.exe

dlv包

下载:在github.com目录下面,这个有点慢

git clone https://github.com/go-delve/delve.git go-delve/delve

安装:

go install github.com/go-delve/delve/cmd/dlv

会在bin目录下面生成dlv.exe

gocode-gomod包

下载:在github.com目录下面,这个有点慢

git clone https://github.com/stamblerre/gocode.git stamblerre/gocode

安装:

go install github.com/stamblerre/gocode

在bin目录下面会出现gocode-gomod.exe

godef包

下载:在github.com目录下面,这个有点慢

git clone https://github.com/rogpeppe/godef.git rogpeppe/godef

安装:

go install github.com/rogpeppe/godef

在bin目录下面会出现godef.exe文件

goreturns包

下载:在github.com目录下面,这个有点慢

git clone https://github.com/sqs/goreturns.git sqs/goreturns

安装:

go install github.com/sqs/goreturns

在bin目录下会生成goreturns.exe

lint包

下载:在golang.org/x目录下面

git clone https://github.com/golang/lint.git lint

安装:

go install golang.org/x/lint/golint

在bin下面会出现golint.exe

over~~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值