按照VSCode的提示点击“安装”,如果失败,需要按照如下步骤安装依赖。
1、解决屏蔽墙
1.1、修改hosts文件
140.82.113.3 github.com
199.232.5.194 github.global.ssl.fastly.net
1.2、刷新DNS缓存
ipconfig /flushdns
2、安装步骤
2.1、下载github源码
go get -v github.com/ramya-rao-a/go-outline
go get -v github.com/acroca/go-symbols
go get -v github.com/mdempsky/gocode
go get -v github.com/rogpeppe/godef
go get -v github.com/zmb3/gogetdoc
go get -v github.com/fatih/gomodifytags
go get -v sourcegraph.com/sqs/goreturns
go get -v github.com/cweill/gotests/gotests
go get -v github.com/josharian/impl
go get -v github.com/haya14busa/goplay/cmd/goplay
go get -v github.com/uudashr/gopkgs/cmd/gopkgs
go get -v github.com/davidrjenni/reftools/cmd/fillstruct
go get -v github.com/alecthomas/gometalinter
2.2、克隆golang.org工具源码
在%GOPATH%\src\目录下,建立路径golang.org\x
进入到%GOPATH%\src\golang.org\x,下载需要工具的源码
git clone https://github.com/golang/tools.git
git clone https://github.com/golang/mod.git
git clone https://github.com/golang/xerrors.git
git clone https://github.com/golang/lint.git
git clone https://github.com/golang/net.git
clone完成后,会生成一个tools文件夹,这样工具所需要的源码已经准备好了。
2.2.1、遇见异常
remote: Enumerating objects: 33, done.
remote: Counting objects: 100% (33/33), done.
remote: Compressing objects: 100% (8/8), done.
error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
解决方案:执行下面两行命令
git config --global http.postBuffer 524288000
git config --global http.sslVerify "false"
2.3、安装工具
go install github.com/ramya-rao-a/go-outline
go install github.com/acroca/go-symbols
go install github.com/mdempsky/gocode
go install github.com/rogpeppe/godef
go install github.com/zmb3/gogetdoc
go install github.com/fatih/gomodifytags
go install sourcegraph.com/sqs/goreturns
go install github.com/cweill/gotests/gotests
go install github.com/josharian/impl
go install github.com/haya14busa/goplay/cmd/goplay
go install github.com/uudashr/gopkgs/cmd/gopkgs
go install github.com/davidrjenni/reftools/cmd/fillstruct
go install github.com/alecthomas/gometalinter
go install golang.org/x/tools/cmd/godoc
go install golang.org/x/lint/golint
go install golang.org/x/tools/cmd/gorename
go install golang.org/x/tools/cmd/goimports
go install golang.org/x/tools/cmd/guru
2.4、集成到系统环境中
将刚才生成在%GOPATH%\bin
文件夹中的文件移动到%GOROOT%\bin
文件夹中,重启VSCode。