解决vscode中golang插件依赖安装失败问题

Posted tingguoguoyo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决vscode中golang插件依赖安装失败问题相关的知识,希望对你有一定的参考价值。

vscode中安装ms-vscode.go插件后可以开启对go语言的支持,ms-vscode.go插件需要依赖一些工具,安装完成后提示

Installing github.com/nsf/gocode SUCCEEDED
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 SUCCEEDED
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 golang.org/x/lint/golint FAILED
Installing github.com/cweill/gotests/... FAILED
Installing github.com/derekparker/delve/cmd/dlv SUCCEEDED

8 tools failed to install.

由于网络原因,一些依赖工具无法正常安装,需要进行手动安装.

以下为手动安装的工具的步骤:

  1. %GOPATH%src目录下,建立路径golang.orgx

  2. 进入到%GOPATH%srcgolang.orgx,下载需要工具的源码git clone https://github.com/golang/tools.git tools

  3. clone完成后,会生成一个tools文件夹,这样工具所需要的源码已经准备好了

  4. 进入到%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
  5. 单独处理golint,golint的源码位于https://github.com/golang/lint,进入%GOPATH%srcgolang.orgx后执行git clone https://github.com/golang/lint下载golint需要的源码

  6. 进入到%GOPATH%下,执行go install github.com/golang/lint/golint

以上是关于解决vscode中golang插件依赖安装失败问题的主要内容,如果未能解决你的问题,请参考以下文章

彻底解决go get golang.org/x等包失败与VSCode golang插件安装失败问题

彻底解决go get golang.org/x等包失败与VSCode golang插件安装失败问题

VSCode 安装 Go 插件依赖失败

解决 Golang VS Code 插件下载安装失败

解决 Golang VS Code 插件下载安装失败

vscode安装golang插件