When running go mod download the warning (warning: pattern "all" matched no module dependencies) is shown and none of the modules in my go.mod file are download to the local cache.
I've spent the last hour on google trying to find similar errors but have been stuck with the only results being broken CI build logs.
My go.mod file is as follows:
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
)
I would expect go mod download to pull all of the modules to the local cache but instead I get the warning and nothing is downloaded.
Modules may be downloaded directly from version control repositories or from module proxy servers. A module is identified by a module path, which is declared in a go. mod file, together with information about the module's dependencies. The module root directory is the directory that contains the go.
Go 1.11 introduces the go mod download command, which takes go. mod and go. sum files and downloads the dependencies from them instead of using the source code. As these files don't change frequently (unless you are updating the dependencies), they can be simply cached by the COPY command from Dockerfile.
In module-aware mode downloaded dependencies are still downloaded to GOPATH/pkg/mod and installed commands to GOPATH/bin , unless otherwise set. If a dependency is tagged v2. 0.0 or higher and contains no go. mod file it is suffixed with +incompatible (likewise for pseudo-versions, e.g., v2. 0.1-0.
Try enabling go modules. This works for me with go 1.12
GO111MODULE=on go mod download
Note: If you're working inside $GOPATH/src, go modules are disabled by default and can be enabled by setting GO111MODULE=on.
From 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.)
I have had the same issue and I resolved it by changing the version of go to v1.11.9.
go mod download
go: modules disabled inside GOPATH/src by GO111MODULE=auto; see 'go help modules'
export GO111MODULE=on
Coming there from the similar issue by running Dockerfile.
Dockerfile:
ENV GO111MODULE=on
RUN go mod download
RUN go mod verify
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With