Skip to content

cmd/go: 'go get -d' in a lazy module should promote transitive imports of the named package(s) to roots #45979

Closed
@bcmills

Description

@bcmills

(This is a pre-release cleanup needed for #36460, noticed during testing.)

In go 1.17 modules, we maintain the invariant that the modules providing all packages transitively imported by the main module are listed explicitly in its go.mod file.

go get currently adds a requirement on the module(s) providing the package(s) requested on the command line, but not their transitive imports. (This matches the behavior of go get in pre-1.17 modules.)

However, I expect that most users who run go get on a package will intend to actually import that package. If that is the case, then if they are in the default -mod=readonly mode their builds involving that package will fail until they run go mod tidy.

I would rather that go get make the requested package importable right away, with go mod tidy only needed to clean up any extraneous dependencies afterward. To make that work for go 1.17 modules, go get should be changed to add explicit requirements for all of the indirectly-imported packages too.

CC @jayconrod @matloob

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions