Skip to content

cmd/go: pass the -x output as a Context key instead of hard-coding os.Stderr #56886

@bcmills

Description

@bcmills

When we run go build -x, we send a bunch of extra logging to os.Stderr. That's fine in production code, but it makes unit-testing unpleasant: if tests run in parallel with cfg.BuildX set to true, the logging from the tests ends up all jumbled together.

We're already threading through a context.Context argument to many functions for tracing (see cmd/go.maybeStartTrace). We should also use that argument for output streams in order to better isolate tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions