Ctrl+Shift+P输入Go:Install/Update Tools命令
Installing 16 tools at D:\golang;\bin gocode gopkgs go-outline go-symbols guru gorename gomodifytags goplay impl fillstruct godef godoc goreturns golint gotests dlv Installing nsf/gocode SUCCEEDED Installing github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDED Installing ramya-rao-a/go-outline FAILED Installing acroca/go-symbols FAILED Installing golang.org/x/tools/cmd/guru FAILED Installing golang.org/x/tools/cmd/gorename FAILED Installing fatih/gomodifytags SUCCEEDED Installing github.com/haya14busa/goplay/cmd/goplay SUCCEEDED Installing josharian/impl FAILED Installing github.com/davidrjenni/reftools/cmd/fillstruct SUCCEEDED Installing rogpeppe/godef SUCCEEDED Installing golang.org/x/tools/cmd/godoc FAILED Installing sqs/goreturns FAILED Installing github.com/golang/lint/golint FAILED Installing cweill/gotests... FAILED Installing github.com/derekparker/delve/cmd/dlv SUCCEEDED 9 tools failed to install.
可以看到有些安装成功,而golang.org/x/tools下的失败了。
go-outline:
Error: Command failed: C:\Go\bin\go.exe get -u -v https://github.com/ramya-rao-a/go-outline
https://github.com//ramya-rao-a/go-outline (download)
Fetching https://golang.org/x/tools/go/b>uildutil?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1:dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package golang.org/x/tools/go/buildutil: unrecognized import path "golang.org/x/tools/go/buildutil" (https fetch: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
https://github.com/ramya-rao-a/go-outline (download)
Fetching https://golang.org/x/tools/go/buildutil?go-get=1
https fetch failed: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
package https:://golang.org/x/tools/go/buildutil: unrecognized import path "https://golang.org/x/tools/go/buildutil" (https fetch: Get https://golang.org/x/tools/go/buildutil?go-get=1: dial tcp 216.239.37.1:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
根据报错提示可以看到,有些工具实际是请求了https://golang.org域名下的内容,而众所周知的原因是被屏蔽了,所以只能进行本地安装。
进入vscode终端,执行以下命令:
mkdir -p $GOPATH/src/golang.org/x cd $GOPATH/src/golang.org/x git clone https://github.com/golang/tools.git PS D:\golang\src\golang.org\x> git clone https://github.com/golang/tools.git Cloning into 'tools'... remote: Counting objects: 19732, done. remote: Compressing objects: 100% (18/18), done. Receiving objects: 5% (1089/19732), 404.01 KiB | 54.00 KiB/s PS D:\golang\src\golang.org\x> git clone https://github.com/golang/lint.git Cloning into 'lint'... remote: Counting objects: 718, done. remote: Total 718 (delta 1), reused 1 (delta 1), pack-reused 716 Receiving objects: 100% (718/718), 320.89 KiB | 101.00 KiB/s, done. Resolving deltas: 100% (424/424), done.
再次Ctrl+Shift+P输入Go:Install/Update Tools命令