Skip to content

cmd/go: 'go get' should consider test dependencies in module mode #32037

@jayconrod

Description

@jayconrod

Since CL 174099, go get in module mode expands each of its arguments to a set of packages, then upgrades or downgrades the modules providing those packages. If the -u flag is given, modules providing transitively imported packages will also be upgraded, but this does not consider test imports.

In 1.12, go get only considered modules: command line arguments were matched against modules in the build list. There was no need to consider test dependencies, since this is not a meaningful concept at the module level.

With the new behavior, we upgrade fewer modules, and there's no convenient way to upgrade test dependencies for the main module. all is the only pattern that considers test dependencies, and it includes test dependencies for packages in other modules.

I propose we bring back the -t flag in module mode. The description for go get -t in GOPATH mode is:

The -t flag instructs get to also download the packages required to build
the tests for the specified packages.

The change to flip this back on would be pretty small. However, this would be a fairly visible behavioral change after the 1.13 freeze, so perhaps we should wait for 1.14. Alternatively, we could consider test dependencies by default.

cc @rsc @bcmills @thepudds

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions