原文链接 1 https://blog.csdn.net/shenhonglei1234/article/details/107933030
vscode插件安装失败
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 #vscode插件安装失败 Installing 7 tools at /Users /honglei/dev/go/bin in module mode. gocode gopkgs go-outline gocode-gomod godef goreturns golint Installing github.com/cweill/gotests/... FAILED Installing github.com/mdempsky/gocode FAILED Installing github.com/fatih/gomodifytags FAILED Installing github.com/uudashr/gopkgs/v2/cmd/gopkgs FAILED Installing github.com/josharian/impl FAILED Installing github.com/ramya-rao-a/go-outline FAILED Installing github.com/davidrjenni/reftools/cmd/fillstruct FAILED Installing github.com/stamblerre/gocode FAILED Installing github.com/haya14busa/goplay/cmd/goplay FAILED Installing github.com/rogpeppe/godef FAILED Installing github.com/godoctor/godoctor FAILED Installing github.com/sqs/goreturns FAILED Installing github.com/go-delve/delve/cmd/dlv FAILED Installing golang.org/x/lint/golint FAILED
解决办法
Go 1.13 and above: Open your terminal and execute
1 2 $ go env -w GO111MODULE =on $ go env -w GOPROXY =https://goproxy.cn,direct
macOS or Linux: Open your terminal and execute
1 2 $ export GO111MODULE =on $ export GOPROXY =https://goproxy.cn
or
1 2 3 $ echo "export GO111MODULE=on" >> ~/.profile $ echo "export GOPROXY=https://goproxy.cn" >> ~/.profile $ source ~/.profile
Windows: Open your terminal and execute
1 2 C :\\> $env:GO111MODULE = "on" C :\\> $env:GOPROXY = "<https://goproxy.cn>"
or
1 2 3 4 5 6 7 8 9 10 11 12 1. Open the Start Search , type in "env" 2. Choose the "Edit the system environment variables" 3. Click the "Environment Variables…" button4. Under the "User variables for <YOUR_USERNAME>" section (the upper half)5. Click the "New..." button6. Choose the "Variable name" input bar, type in "GO111MODULE" 7. Choose the "Variable value" input bar, type in "on" 8. Click the "OK" button9. Click the "New..." button10. Choose the "Variable name" input bar, type in "GOPROXY" 11. Choose the "Variable value" input bar, type in "<https://goproxy.cn>" 12. Click the "OK" button
配置代理后的安装效果
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 Tools environment: GOPATH =/Users /honglei/dev/goInstalling 17 tools at /Users /honglei/dev/go/bin in module mode. gocode gopkgs go-outline go-symbols guru gorename gotests gomodifytags impl fillstruct goplay godoctor dlv gocode-gomod godef goreturns golint Installing github.com/mdempsky/gocode (/Users /honglei/dev/go/bin/gocode) SUCCEEDED Installing github.com/uudashr/gopkgs/v2/cmd/gopkgs (/Users /honglei/dev/go/bin/gopkgs) SUCCEEDED Installing github.com/ramya-rao-a/go-outline (/Users /honglei/dev/go/bin/go-outline) SUCCEEDED Installing github.com/acroca/go-symbols (/Users /honglei/dev/go/bin/go-symbols) SUCCEEDED Installing golang.org/x/tools/cmd/guru (/Users /honglei/dev/go/bin/guru) SUCCEEDED Installing golang.org/x/tools/cmd/gorename (/Users /honglei/dev/go/bin/gorename) SUCCEEDED Installing github.com/cweill/gotests/... (/Users /honglei/dev/go/bin/gotests) SUCCEEDED Installing github.com/fatih/gomodifytags (/Users /honglei/dev/go/bin/gomodifytags) SUCCEEDED Installing github.com/josharian/impl (/Users /honglei/dev/go/bin/impl) SUCCEEDED Installing github.com/davidrjenni/reftools/cmd/fillstruct (/Users /honglei/dev/go/bin/fillstruct) SUCCEEDED Installing github.com/haya14busa/goplay/cmd/goplay (/Users /honglei/dev/go/bin/goplay) SUCCEEDED Installing github.com/godoctor/godoctor (/Users /honglei/dev/go/bin/godoctor) SUCCEEDED Installing github.com/go-delve/delve/cmd/dlv (/Users /honglei/dev/go/bin/dlv) SUCCEEDED Installing github.com/stamblerre/gocode (/Users /honglei/dev/go/bin/gocode-gomod) SUCCEEDED Installing github.com/rogpeppe/godef (/Users /honglei/dev/go/bin/godef) SUCCEEDED Installing github.com/sqs/goreturns (/Users /honglei/dev/go/bin/goreturns) SUCCEEDED Installing golang.org/x/lint/golint (/Users /honglei/dev/go/bin/golint) SUCCEEDED All tools successfully installed. You are ready to Go :).
注意
如果配置代理后还是安装失败,重启下电脑试试。
go env 命令检查配置是否正确。