VS Code 安装了Go插件以后,还需要安装一些辅助的插件但是呢 如果系统安装基本上都是失败。google 的访问被限制的缘故吧。网上找了一些文章 都或多或少的有那么点缺陷,安装的时候报错挺让人抓狂的。于是乎自己看着别人的文章 整了半天终于把这些东西手动安装上了,记录一下。
VSCode里面 Shift+Alt+P 调出下面这个命令框 然后输入Go:Install/Update Tools 之后就会显示出你需要安装的插件。
像下面这个样子还挺多的都打上勾然后点确定让系统自己安装。也不用着急基本上都显示
FAILED,这个没事我们需要获得系统的输出来手动安装所以等着都显示完,基本上像下面这个样子
go.toolsGopath setting is not set. Using GOPATH D:workshopgo
Installing 17 tools at D:workshopgobin in module mode.
gocode
gopkgs
go-outline
go-symbols
guru
gorename
gotests
gomodifytags
impl
fillstruct
goplay
godoctor
dlv
gocode-gomod
godef
goreturns
golint
Installing http://github.com/mdempsky/gocode FAILED
Installing http://github.com/uudashr/gopkgs/v2/cmd/gopkgs FAILED
Installing http://github.com/ramya-rao-a/go-outline FAILED
Installing http://github.com/acroca/go-symbols FAILED
Installing http://golang.org/x/tools/cmd/guru FAILED
Installing http://golang.org/x/tools/cmd/gorename FAILED
Installing http://github.com/cweill/gotests/... FAILED
Installing http://github.com/fatih/gomodifytags FAILED
Installing http://github.com/josharian/impl FAILED
Installing http://github.com/davidrjenni/reftools/cmd/fillstruct FAILED
Installing http://github.com/haya14busa/goplay/cmd/goplay FAILED
Installing http://github.com/godoctor/godoctor FAILED
Installing http://github.com/go-delve/delve/cmd/dlv FAILED
Installing http://github.com/stamblerre/gocode FAILED
Installing http://github.com/rogpeppe/godef FAILED
Installing http://github.com/sqs/goreturns FAILED
Installing http://golang.org/x/lint/golint FAILED
基本的手动思路就是
1.github 上找到对应的地址并clone 到本地。比如http://github.com/davidrjenni/reftools/cmd/fillstruct 这个
2.放到本地的指定目录src里面 目录关系就是按照地址的这个顺序 src/http://github.com/davidrjenni/reftools/cmd/fillstruct
3.打开终端 进入bin目录,输入go install github.com/davidrjenni/reftools/cmd/fillstruct
install 后面这个地址必须跟你src里面地址一致,不然就会报错。
4.然后就是等着结果了如果成功就什么都不显示 在bin目录里面会生成一个fillstruct.exe的程序,失败的话会有提示出来。
总结一下遇到的坑:
1.就是github clone之后没有放到合适的目录里面这样编译的时候找不到文件这个错误我出来好多次。
2.有几个模块编译的时候是需要其他模块的这个还是要从github上 clone出来放到指定目录。3.go install的时候 要注意 Installing http://github.com/uudashr/gopkgs/v2/cmd/gopkgs 这个是之前报错的那个信息 我们执行的时候就是执行 http://github.com/uudashr/gopkgs/v2/cmd/gopkgs这一串。
4.比如我们要github clone http://github.com/davidrjenni/reftools这个的时候 我是先在src目录下新建个http://github.com 目录 然后新建 davidrjenni目录 然后进入这个目录再执行 git clone davidrjenni/reftools 这样执行 go install的时候才能对的上。