美文网首页
vscode手动 安装go插件

vscode手动 安装go插件

作者: 雪上霜 | 来源:发表于2021-04-11 11:02 被阅读0次

    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的扩展


      在这里插入图片描述

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

    4. 自动弹出来的go插件安装界面长下面这个样子,点那个Install All 就行[图片上传失败...(image-3752f-1618110027521)]

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

      gopkgs

      go-outline

      go-symbols

      guru

      gorename

      gotests

      gomodifytags

      impl

      fillstruct

      goplay

      godoctor

      dlv

      gocode-gomod

      godef

      goreturns

      但是我的安装全部失败:

    在这里插入图片描述

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

    3.问题解决办法

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

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

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

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

    2. 下面就一个一个的下载包

      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@latest

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

      [图片上传失败...(image-6586c3-1618110027520)]

      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@latest

      go-symbols包

      下载:在github.com目录下面

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

      安装:

      go install github.com/acroca/go-symbols@latest

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

      [图片上传失败...(image-d73fd4-1618110027520)]

      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@latest

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

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

      在这里插入图片描述

      gotests包

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

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

      安装:

      go install github.com/cweill/gotests@latest

      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@latest

      在bin下会出现一个gomodifytags.exe

      在这里插入图片描述

      impl包

      下载:在github.com目录下面

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

      安装:

      go install github.com/josharian/impl@latest

      在bin下会出现impl.exe

      在这里插入图片描述

      fillstruct包

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

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

      安装:

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

      在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@latest

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

      在这里插入图片描述

      godoctor包

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

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

      安装:

      go install github.com/godoctor/godoctor@latest

      在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@latest

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

      gocode-gomod包

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

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

      安装:

      go install github.com/stamblerre/gocode@latest

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

      godef包

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

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

      安装:

      go install github.com/rogpeppe/godef@latest

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

      goreturns包

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

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

      安装:

      go install github.com/sqs/goreturns@latest

      在bin目录下会生成goreturns.exe

      lint包

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

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

      安装:

      go install golang.org/x/lint/golint@latest

      在bin下面会出现golint.exe

    相关文章

      网友评论

          本文标题:vscode手动 安装go插件

          本文链接:https://www.haomeiwen.com/subject/xtlakltx.html