项目场景:
想要在VSCode安装go环境,但是gopls下载失败,导致vscode无法使用language server
问题描述
自动下载失败,在打开命令面板(Ctrl+shift+P)之后,输入go install/update 下载也失败
$ go install -v golang.org/x/tools/gopls@latestgo: golang.org/x/tools/gopls@latest: module golang.org/x/tools/gopls: Get "https://proxy.golang.org/golang.org/x/tools/gopls/@v/list": dial tcp 172.217.163.49: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..
原因分析:
查找资料之后发现是网络连接错误。参见https://zhuanlan.zhihu.com/p/320343679
解决方案:
启动vscode 时使用代理网络选项。
code <你的目录> --proxy-server="http://127.0.0.1:7890"
参考参考https://suiahae.me/Set-proxy-for-Visual-Studio-Code-on-Windows/