30秒解决vscode中golang插件依赖安装失败问题

vscode插件安装失败

#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

$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn,direct

done.

macOS or Linux

Open your terminal and execute

$ export GO111MODULE=on
$ export GOPROXY=https://goproxy.cn

or

$ echo "export GO111MODULE=on" >> ~/.profile
$ echo "export GOPROXY=https://goproxy.cn" >> ~/.profile
$ source ~/.profile

done.

Windows

Open your terminal and execute

C:\> $env:GO111MODULE = "on"
C:\> $env:GOPROXY = "https://goproxy.cn"

or

1. Open the Start Search, type in "env"
2. Choose the "Edit the system environment variables"
3. Click the "Environment Variables…" button
4. Under the "User variables for <YOUR_USERNAME>" section (the upper half)
5. Click the "New..." button
6. Choose the "Variable name" input bar, type in "GO111MODULE"
7. Choose the "Variable value" input bar, type in "on"
8. Click the "OK" button
9. Click the "New..." button
10. 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

done.

配置代理后的安装效果

Tools environment: GOPATH=/Users/honglei/dev/go
Installing 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 命令检查配置是否正确。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

[shenhonglei]

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值