按照VSCode的提示点击“安装”,如果失败,需要按照如下步骤安装依赖。

1、解决屏蔽墙

1.1、修改hosts文件

  1. 140.82.113.3 github.com
  2. 199.232.5.194 github.global.ssl.fastly.net

1.2、刷新DNS缓存

  1. ipconfig /flushdns

2、安装步骤

2.1、下载github源码

  1. go get -v github.com/ramya-rao-a/go-outline
  2. go get -v github.com/acroca/go-symbols
  3. go get -v github.com/mdempsky/gocode
  4. go get -v github.com/rogpeppe/godef
  5. go get -v github.com/zmb3/gogetdoc
  6. go get -v github.com/fatih/gomodifytags
  7. go get -v sourcegraph.com/sqs/goreturns
  8. go get -v github.com/cweill/gotests/gotests
  9. go get -v github.com/josharian/impl
  10. go get -v github.com/haya14busa/goplay/cmd/goplay
  11. go get -v github.com/uudashr/gopkgs/cmd/gopkgs
  12. go get -v github.com/davidrjenni/reftools/cmd/fillstruct
  13. go get -v github.com/alecthomas/gometalinter

2.2、克隆golang.org工具源码

在%GOPATH%\src\目录下,建立路径golang.org\x
进入到%GOPATH%\src\golang.org\x,下载需要工具的源码

  1. git clone https://github.com/golang/tools.git
  2. git clone https://github.com/golang/mod.git
  3. git clone https://github.com/golang/xerrors.git
  4. git clone https://github.com/golang/lint.git
  5. git clone https://github.com/golang/net.git


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

2.2.1、遇见异常

  1. remote: Enumerating objects: 33, done.
  2. remote: Counting objects: 100% (33/33), done.
  3. remote: Compressing objects: 100% (8/8), done.
  4. error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
  5. fatal: the remote end hung up unexpectedly
  6. fatal: early EOF
  7. fatal: index-pack failed

解决方案:执行下面两行命令

  1. git config --global http.postBuffer 524288000
  2. git config --global http.sslVerify "false"


2.3、安装工具

  1. go install github.com/ramya-rao-a/go-outline
  2. go install github.com/acroca/go-symbols
  3. go install github.com/mdempsky/gocode
  4. go install github.com/rogpeppe/godef
  5. go install github.com/zmb3/gogetdoc
  6. go install github.com/fatih/gomodifytags
  7. go install sourcegraph.com/sqs/goreturns
  8. go install github.com/cweill/gotests/gotests
  9. go install github.com/josharian/impl
  10. go install github.com/haya14busa/goplay/cmd/goplay
  11. go install github.com/uudashr/gopkgs/cmd/gopkgs
  12. go install github.com/davidrjenni/reftools/cmd/fillstruct
  13. go install github.com/alecthomas/gometalinter
  14. go install golang.org/x/tools/cmd/godoc
  15. go install golang.org/x/lint/golint
  16. go install golang.org/x/tools/cmd/gorename
  17. go install golang.org/x/tools/cmd/goimports
  18. go install golang.org/x/tools/cmd/guru

2.4、集成到系统环境中

将刚才生成在%GOPATH%\bin文件夹中的文件移动到%GOROOT%\bin文件夹中,重启VSCode。