go - 使用go mod下载时出现 "Pattern matched no module dependencies"是什么原因?

标签 go module

运行 go mod download 时会显示警告(警告:模式“全部”不匹配任何模块依赖项)并且我的 go.mod 文件中没有任何模块下载到本地缓存。

我花了最后一个小时在谷歌上试图找到类似的错误,但一直坚持唯一的结果是破坏 CI 构建日志。

我的go.mod文件如下:

module github.com/j4ng5y/scraper-api

go 1.12

require (
    github.com/PuerkitoBio/goquery v1.5.0 // indirect
    github.com/antchfx/htmlquery v1.0.0 // indirect
    github.com/antchfx/xmlquery v1.0.0 // indirect
    github.com/antchfx/xpath v0.0.0-20190319080838-ce1d48779e67 // indirect
    github.com/go-yaml/yaml v2.1.0+incompatible
    github.com/gobwas/glob v0.2.3 // indirect
    github.com/gocolly/colly v1.2.0 // indirect
    github.com/gorilla/mux v1.7.1
    github.com/kennygrant/sanitize v1.2.4 // indirect
    github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
    github.com/temoto/robotstxt v0.0.0-20180810133444-97ee4a9ee6ea // indirect
    golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 // indirect
    google.golang.org/appengine v1.5.0 // indirect
)

我希望 go mod download 将所有模块拉到本地缓存,但我收到警告并且没有下载任何内容。

最佳答案

尝试启用 go 模块。这适用于 go 1.12

GO111MODULE=on go mod download

注意:如果你在 $GOPATH/src 中工作,go 模块默认是禁用的,可以通过设置 GO111MODULE=on 来启用。

来自 https://blog.golang.org/using-go-modules ,

(Inside $GOPATH/src, for compatibility, the go command still runs in the old GOPATH mode, even if a go.mod is found. See the go command documentation for details.)

关于go - 使用go mod下载时出现 "Pattern matched no module dependencies"是什么原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55788194/

相关文章:

go - 更新 crypto-config.yaml 文件并在网络中更新

json - Golang JSON 到包含 slice 的 map 本身的 map slice (无类型)

interface - Go 中 "interface {}"语法的作用是什么?

java - 如何在maven中管理多应用程序项目?

Go Modules - 目录和包的命名约定

python - 错误 : No module named 'fcntl'

unit-testing - golang中可以跳过init方法吗?

go - 如何拉伸(stretch)条目小部件

module - 重新加载导入的模块

haskell - 如何导入隐藏子模块或实例的模块?