解决:使用VS开发Go时,Go扩展安装失败

报错信息

Installing github.com/nsf/gocode FAILED
Installing github.com/uudashr/gopkgs/cmd/gopkgs SUCCEEDED
Installing github.com/ramya-rao-a/go-outline FAILED
Installing github.com/acroca/go-symbols FAILED
Installing golang.org/x/tools/cmd/guru FAILED
Installing golang.org/x/tools/cmd/gorename FAILED
Installing github.com/fatih/gomodifytags FAILED
...

解决过程

官方Go模块代理说明链接点此处跳转Github

其中在Windows下
打开cmd,依次输入下面语句:

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

在macOS或Linux下
打开终端,依次输入下面语句:

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

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

回到VS code,成功安装所有扩展

Tools environment: GOPATH=C:\Users\mac\go
Installing 10 tools at C:\Users\mac\go\bin in module mode.
  gopkgs
  go-outline
  gotests
  gomodifytags
  impl
  goplay
  dlv
  dlv-dap
  staticcheck
  gopls

Installing github.com/uudashr/gopkgs/v2/cmd/gopkgs (C:\Users\mac\go\bin\gopkgs.exe) SUCCEEDED
Installing github.com/ramya-rao-a/go-outline (C:\Users\mac\go\bin\go-outline.exe) SUCCEEDED
Installing github.com/cweill/gotests/gotests (C:\Users\mac\go\bin\gotests.exe) SUCCEEDED
Installing github.com/fatih/gomodifytags (C:\Users\mac\go\bin\gomodifytags.exe) SUCCEEDED
Installing github.com/josharian/impl (C:\Users\mac\go\bin\impl.exe) SUCCEEDED
Installing github.com/haya14busa/goplay/cmd/goplay (C:\Users\mac\go\bin\goplay.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv (C:\Users\mac\go\bin\dlv.exe) SUCCEEDED
Installing github.com/go-delve/delve/cmd/dlv@master (C:\Users\mac\go\bin\dlv-dap.exe) SUCCEEDED
Installing honnef.co/go/tools/cmd/staticcheck (C:\Users\mac\go\bin\staticcheck.exe) SUCCEEDED
Installing golang.org/x/tools/gopls (C:\Users\mac\go\bin\gopls.exe) SUCCEEDED

All tools successfully installed. You are ready to Go :).

欢迎一键三连~~ ?


版权声明:本文为qq_45827558原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。