When you parse go test -json in CI or an editor, === RUN lines, t.Log output, and t.Error failures all land in one stream. Until now, tools relied on fragile regexes to tell them apart. In Go 1.27, Action: "output" events (each line of test output) gain an optional OutputType field.
The cmd/test2json tool, which converts test text into a JSON stream, now sets three labels. frame marks runner control lines like === RUN and --- FAIL. error tags the first line from Error/Fatal calls in tests and benchmarks, and error-continue marks the rest of a multi-line error. An empty or missing field means a regular log line.
# Filter only t.Error and t.Fatal lines using jq
go test -json ./... | jq -r '
select(.Action == "output" and
(.OutputType == "error" or .OutputType == "error-continue"))
| "\(.Test): \(.Output)"'
In the TestEvent JSON stream, OutputType arrives right next to the output line, so parsers know what is runner framing and what is an actual failure without guessing:
{
"Action": "output",
"Test": "TestCalc",
"Output": "=== RUN TestCalc\n",
"OutputType": "frame"
}
{
"Action": "output",
"Test": "TestCalc",
"Output": " calc_test.go:18: want 4, got 5\n",
"OutputType": "error"
}
{
"Action": "output",
"Test": "TestCalc",
"Output": " extra detail\n",
"OutputType": "error-continue"
}
It doesn't catch everything, though. The test binary injects internal markers for test2json, so OutputType only tags Error/Fatal calls from testing. Errors printed straight to stdout or stderr by your program stay untagged. Use go test -json for multiple packages, or go tool test2json for a single compiled test binary.
