搭建 Go 的开发环境时,我们都需要先安装 go 的安装包,在 windows 下,会自动配置 GOPATH 环境变量。
使用 vscode 开发 go
在 vscode 中新建了一个 go 文件后,vscode 会提示安装go插件 点击install all 后,即使上网的姿势很科学,可能也会安装失败,提示
Installing github.com/mdempsky/gocode FAILED
Installing github.com/uudashr/gopkgs/v2/cmd/gopkgs FAILED
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/cweill/gotests/… FAILED
Installing github.com/fatih/gomodifytags FAILED
Installing github.com/josharian/impl FAILED
Installing github.com/davidrjenni/reftools/cmd/fillstruct FAILED
Installing github.com/haya14busa/goplay/cmd/goplay FAILED
Installing github.com/godoctor/godoctor FAILED
Installing github.com/go-delve/delve/cmd/dlv FAILED
Installing github.com/stamblerre/gocode FAILED
Installing github.com/rogpeppe/godef FAILED
Installing github.com/sqs/goreturns FAILED
Installing golang.org/x/lint/golint FAILED
原因不明,但是有办法解决。 在这种情况下,我们需要 go mod 代理来安装
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.io,direct
重新打开 vscode,点击 install all,即可安装成功
|