一、介绍
目的:本文将主要介绍在windows使用VSCode配置Go语言环境
软件:VSCode
二、安装出现的问题
完整信息如下
Installing 8 tools at D:\GoPath\bin go-outline go-symbols guru gorename dlv godef goreturns golintInstalling golang.org/x/tools/cmd/guru FAILEDInstalling github.com/ramya-rao-a/go-outline FAILEDInstalling golang.org/x/tools/cmd/gorename FAILEDInstalling github.com/derekparker/delve/cmd/dlv SUCCEEDEDInstalling github.com/acroca/go-symbols FAILEDInstalling golang.org/x/tools/cmd/guru FAILEDInstalling github.com/rogpeppe/godef SUCCEEDEDInstalling golang.org/x/tools/cmd/gorename FAILEDInstalling github.com/derekparker/delve/cmd/dlv SUCCEEDEDInstalling github.com/rogpeppe/godef SUCCEEDEDInstalling github.com/sqs/goreturns FAILEDInstalling github.com/golang/lint/golint FAILED6 tools failed to install.go-outline:Error: Command failed: C:\Go\bin\go.exe get -u -v github.com/ramya-rao-a/go-outlinegithub.com/ramya-rao-a/go-outline (download)Fetching https://golang.org/x/tools/go/buildutil?go-get=1https 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.)github.com/ramya-rao-a/go-outline (download)Fetching https://golang.org/x/tools/go/buildutil?go-get=1https 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.)go-symbols:Error: Command failed: C:\Go\bin\go.exe get -u -v github.com/acroca/go-symbolsgithub.com/acroca/go-symbols (download)Fetching https://golang.org/x/tools/go/buildutil?go-get=1https 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.)github.com/acroca/go-symbols (download)Fetching https://golang.org/x/tools/go/buildutil?go-get=1https 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.)guru:Error: Command failed: C:\Go\bin\go.exe get -u -v golang.org/x/tools/cmd/guruFetching https://golang.org/x/tools/cmd/guru?go-get=1https fetch failed: Get https://golang.org/x/tools/cmd/guru?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/cmd/guru: unrecognized import path "golang.org/x/tools/cmd/guru" (https fetch: Get https://golang.org/x/tools/cmd/guru?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.)Fetching https://golang.org/x/tools/cmd/guru?go-get=1https fetch failed: Get https://golang.org/x/tools/cmd/guru?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/cmd/guru: unrecognized import path "golang.org/x/tools/cmd/guru" (https fetch: Get https://golang.org/x/tools/cmd/guru?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.)gorename:Error: Command failed: C:\Go\bin\go.exe get -u -v golang.org/x/tools/cmd/gorenameFetching https://golang.org/x/tools/cmd/gorename?go-get=1https fetch failed: Get https://golang.org/x/tools/cmd/gorename?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/cmd/gorename: unrecognized import path "golang.org/x/tools/cmd/gorename" (https fetch: Get https://golang.org/x/tools/cmd/gorename?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.)Fetching https://golang.org/x/tools/cmd/gorename?go-get=1https fetch failed: Get https://golang.org/x/tools/cmd/gorename?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/cmd/gorename: unrecognized import path "golang.org/x/tools/cmd/gorename" (https fetch: Get https://golang.org/x/tools/cmd/gorename?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.)goreturns:Error: Command failed: C:\Go\bin\go.exe get -u -v github.com/sqs/goreturnsgithub.com/sqs/goreturns (download)Fetching https://golang.org/x/tools/imports?go-get=1https fetch failed: Get https://golang.org/x/tools/imports?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/imports: unrecognized import path "golang.org/x/tools/imports" (https fetch: Get https://golang.org/x/tools/imports?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.)github.com/sqs/goreturns (download)Fetching https://golang.org/x/tools/imports?go-get=1https fetch failed: Get https://golang.org/x/tools/imports?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/imports: unrecognized import path "golang.org/x/tools/imports" (https fetch: Get https://golang.org/x/tools/imports?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.)golint:Error: Command failed: C:\Go\bin\go.exe get -u -v github.com/golang/lint/golintgithub.com/golang/lint (download)Fetching https://golang.org/x/lint?go-get=1https fetch failed: Get https://golang.org/x/lint?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/lint: unrecognized import path "golang.org/x/lint" (https fetch: Get https://golang.org/x/lint?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.)github.com/golang/lint (download)Fetching https://golang.org/x/lint?go-get=1https fetch failed: Get https://golang.org/x/lint?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/lint: unrecognized import path "golang.org/x/lint" (https fetch: Get https://golang.org/x/lint?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.)Installing github.com/sqs/goreturns FAILEDInstalling github.com/golang/lint/golint FAILED6 tools failed to install.go-outline:Error: Command failed: C:\Go\bin\go.exe get -u -v github.com/ramya-rao-a/go-outlinegithub.com/ramya-rao-a/go-outline (download)Fetching https://golang.org/x/tools/go/buildutil?go-get=1https 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.)github.com/ramya-rao-a/go-outline (download)Fetching https://golang.org/x/tools/go/buildutil?go-get=1https 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.)go-symbols:Error: Command failed: C:\Go\bin\go.exe get -u -v github.com/acroca/go-symbolsgithub.com/acroca/go-symbols (download)Fetching https://golang.org/x/tools/go/buildutil?go-get=1https 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.)github.com/acroca/go-symbols (download)Fetching https://golang.org/x/tools/go/buildutil?go-get=1https 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.)guru:Error: Command failed: C:\Go\bin\go.exe get -u -v golang.org/x/tools/cmd/guruFetching https://golang.org/x/tools/cmd/guru?go-get=1https fetch failed: Get https://golang.org/x/tools/cmd/guru?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/cmd/guru: unrecognized import path "golang.org/x/tools/cmd/guru" (https fetch: Get https://golang.org/x/tools/cmd/guru?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.)Fetching https://golang.org/x/tools/cmd/guru?go-get=1https fetch failed: Get https://golang.org/x/tools/cmd/guru?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/cmd/guru: unrecognized import path "golang.org/x/tools/cmd/guru" (https fetch: Get https://golang.org/x/tools/cmd/guru?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.)gorename:Error: Command failed: C:\Go\bin\go.exe get -u -v golang.org/x/tools/cmd/gorenameFetching https://golang.org/x/tools/cmd/gorename?go-get=1https fetch failed: Get https://golang.org/x/tools/cmd/gorename?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/cmd/gorename: unrecognized import path "golang.org/x/tools/cmd/gorename" (https fetch: Get https://golang.org/x/tools/cmd/gorename?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.)Fetching https://golang.org/x/tools/cmd/gorename?go-get=1https fetch failed: Get https://golang.org/x/tools/cmd/gorename?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/cmd/gorename: unrecognized import path "golang.org/x/tools/cmd/gorename" (https fetch: Get https://golang.org/x/tools/cmd/gorename?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.)goreturns:Error: Command failed: C:\Go\bin\go.exe get -u -v github.com/sqs/goreturnsgithub.com/sqs/goreturns (download)# cd D:\GoPath\src\github.com\sqs\goreturns; git pull --ff-onlyfatal: early EOFfatal: The remote end hung up unexpectedlyfatal: index-pack failederror: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054package github.com/sqs/goreturns: exit status 1github.com/sqs/goreturns (download)# cd D:\GoPath\src\github.com\sqs\goreturns; git pull --ff-onlyfatal: early EOFfatal: The remote end hung up unexpectedlyfatal: index-pack failederror: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054package github.com/sqs/goreturns: exit status 1golint:Error: Command failed: C:\Go\bin\go.exe get -u -v github.com/golang/lint/golintgithub.com/golang/lint (download)Fetching https://golang.org/x/lint?go-get=1https fetch failed: Get https://golang.org/x/lint?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/lint: unrecognized import path "golang.org/x/lint" (https fetch: Get https://golang.org/x/lint?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.)github.com/golang/lint (download)Fetching https://golang.org/x/lint?go-get=1https fetch failed: Get https://golang.org/x/lint?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/lint: unrecognized import path "golang.org/x/lint" (https fetch: Get https://golang.org/x/lint?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.)
三、解决方案
进行如下命令进行目录切换:
cd %GOPATH%\src\github.com\golang我这里的GOPATH是在D:\GoPath,大家这里一定要注意些如果src目录下面没有github.com\golang文件夹请自行创建完成目录切换后,开始下载插件包,在切换后的目录下进入命令行界面,可以用git bash:
git clone tools当下载完成后,你会发现%GOPATH%\src\github.com\golang多了一个tools目录
需要把tools目录下的所有文件拷贝到%GOPATH%\src\golang.org\x\tools下,如果没有自行创建。
这时我想偷个懒,再重新打开VSCode时,发现只有一个安装包安装失败
这时可以转换成手动安装:
将目录切换到GOPATH目录下,执行相关的go install 命令
go get -u -v github.com/ramya-rao-a/go-outlinego get -u -v github.com/acroca/go-symbolsgo get -u -v github.com/mdempsky/gocodego get -u -v github.com/rogpeppe/godefgo get -u -v golang.org/x/tools/cmd/godocgo get -u -v github.com/zmb3/gogetdocgo get -u -v github.com/golang/lint/golintgo get -u -v github.com/fatih/gomodifytagsgo get -u -v golang.org/x/tools/cmd/gorenamego get -u -v sourcegraph.com/sqs/goreturnsgo get -u -v golang.org/x/tools/cmd/goimportsgo get -u -v github.com/cweill/gotests/...go get -u -v golang.org/x/tools/cmd/gurugo get -u -v github.com/josharian/implgo get -u -v github.com/haya14busa/goplay/cmd/goplaygo get -u -v github.com/uudashr/gopkgs/cmd/gopkgsgo get -u -v github.com/davidrjenni/reftools/cmd/fillstructgo get -u -v github.com/alecthomas/gometalintergometalinter --install
四、参考资料