Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: document using 'go list' to download modules needed to build packages #38031

Closed
jayconrod opened this issue Mar 23, 2020 · 4 comments
Closed
Labels
Documentation FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@jayconrod
Copy link
Contributor

go list -test ./... can be used to download the modules needed to build tests of the packages matched by ./.... This is usually a smaller set of modules than go mod download all (or equivalent go mod download) would select, so it's a useful command when building small Docker images.

This should be documented as a FAQ on https://github.com/golang/go/wiki/Modules.

Related #36460: fewer modules will be downloaded by go mod download all when lazy module loading is implemented.

@jayconrod jayconrod added Documentation NeedsFix The path to resolution is known, but the work has not been done. modules labels Mar 23, 2020
@jayconrod jayconrod added this to the Unreleased milestone Mar 23, 2020
@jayconrod jayconrod self-assigned this Mar 23, 2020
@mvdan
Copy link
Member

mvdan commented Mar 23, 2020

It also wasn't clear to me that go mod download was synonymous with go mod download all. Maybe go help mod download could be made a bit more explicit.

@mvdan
Copy link
Member

mvdan commented Mar 24, 2020

Two more genuine use cases occurred to me, even in the face of lazy module loading being impemented:

  • If one only wants non-test deps to be downloaded, go list ./... can download far less than go list -test ./...
  • If one only wants deps required for a specific set of tags, go list -tags=xxx ./... might also avoid other unnecessary deps

And, like @jayconrod mentioned on slack, if one only needs the deps for a subset of the packages, like go list ./cmd/... if that's all that one needs to build offline later.

@jayconrod
Copy link
Contributor Author

@gopherbot
Copy link

Change https://golang.org/cl/225201 mentions this issue: cmd/go: clarify behavior with no arguments in 'go help mod download'

@golang golang locked and limited conversation to collaborators Mar 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants