Skip to content

proposal: testing: optional prefix for error output #68613

Description

@firelizzard18

Proposal Details

Proposal

I propose the addition of a go test flag that will add a prefix to the output of t.Error(f) and t.Fatal(f). For example, go test -errlogprefix "Error: " would cause t.Error("it failed") to output Error: it failed.

Alternatively a flag that specifies a template for error message printing would be even more useful, something like -errlogformat "Error: {{.Message}}". Beyond the basic Message field, the context could include additional info such as the location.

Motivation

When the user executes a Go test in vscode (with vscode-go), I want to tell the user what caused the error to fail. vscode provides a mechanism for this - when I report the failure of the test, I can provide messages associated with that failure. However, I have no way of knowing which messages should be associated with the failure. However if this proposal is accepted, I could specify some sequence of bytes as the prefix, and detect that sequence of bytes when processing test output.

Activity

  1. added this to the Proposal milestone on Jul 26, 2024
  2. gabyhelp commented on Jul 26, 2024

    @gabyhelp
  3. seankhliao commented on Jul 26, 2024

    @seankhliao
    Member

    Duplicate of #47080

  4. locked and limited conversation to collaborators on Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions