获取:go:错误加载模块要求

Getting: go: error loading module requirements

我正在尝试 运行 从 git 下载的 SLACK 机器人的 go 脚本。 https://github.com/nlopes/slack/blob/master/examples/websocket/websocket.go#L34

我在 websocket.go

中替换了我的机器人的授权码
rchughta@C02WW32YHTD6 ~/g/s/e/websocket> go run websocket.go
go: finding github.com/pmezard/go-difflib v1.0.0
go: finding github.com/davecgh/go-spew v1.1.1
go: finding github.com/stretchr/testify v1.2.2
go: finding github.com/pkg/errors v0.8.0
go: finding github.com/gorilla/websocket v1.2.0
go: github.com/gorilla/websocket@v1.2.0: unknown revision v1.2.0
go: github.com/davecgh/go-spew@v1.1.1: unknown revision v1.1.1
go: github.com/pkg/errors@v0.8.0: unknown revision v0.8.0
go: github.com/stretchr/testify@v1.2.2: unknown revision v1.2.2
go: github.com/pmezard/go-difflib@v1.0.0: unknown revision v1.0.0
go: error loading module requirements

确保您使用的是最新的 Go 1.13.1。

如果 go mod tidy 没有解决问题,请检查简单的 go get github.com/gorilla/websocket@v1.2.0 是否有效。

如果没有,可能是,as in this thread,代理配置问题:这取决于您的本地环境,您可能需要设置公司代理服务器才能获取任何内容。


2020 年 8 月更新:请注意 with Go 1.15

The GOPROXY environment variable now supports skipping proxies that return errors.

Proxy URLs may now be separated with either commas (,) or pipe characters (|).

  • If a proxy URL is followed by a comma, the go command will only try the next proxy in the list after a 404 or 410 HTTP response.
  • If a proxy URL is followed by a pipe character, the go command will try the next proxy in the list after any error.

Note that the default value of GOPROXY remains https://proxy.golang.org,direct, which does not fall back to direct in case of errors.

这似乎是 GOPROXY 设置的问题。 go env 的输出是什么?