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 命令检查配置是否正确。