cmd/go 'go mod download <package name>' fetches all modules if module cache is empty/missing #40245
Labels
FrozenDueToAge
GoCommand
cmd/go
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://golang.org/ref/mod#tmp_28 describes how
go mod download
can be used to pre-fill the module cache, and how the module paths/patterns to download can be specified. In practice, we find executing this command with an empty/missing module cache causes the download of all modules ingo.mod
and their dependencies, rather than just the specified module path.A minimal example to reproduce this (using Docker to ensure a clean Go environment each time) is at https://github.com/mikemoate/go-mod-download-issue the output of this is:
docker build
Outputgo.mod
ContentYou can clearly see the get for module
github.com/google/uuid
, despite this not being requested and not being a dependency of the requested modulersc.io/quote
Our use case here is to pre-fetch private modules individually, specifying appropriate credentials for each, ahead of performing a build. This fails because the attempt to fetch an individual private module, tries to download all the private modules in
go.mod
.What did you expect to see?
Only the requested module is downloaded.
What did you see instead?
All modules were downloaded.
The text was updated successfully, but these errors were encountered: