parser

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package parser contains bounded decoders for tool output formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BenchmarkReport

type BenchmarkReport struct {
	Benchmarks []BenchmarkResult
}

BenchmarkReport contains all parsed benchmark results.

func ParseBenchmarks

func ParseBenchmarks(r io.Reader) (BenchmarkReport, error)

ParseBenchmarks parses completed Go benchmark output from r.

type BenchmarkResult

type BenchmarkResult struct {
	Name    string
	Samples []BenchmarkSample
	Median  float64
}

BenchmarkResult groups measurements for one benchmark name.

type BenchmarkSample

type BenchmarkSample struct {
	NsOp float64
}

BenchmarkSample is one parsed benchmark measurement.

type CoverageBlock

type CoverageBlock struct {
	File                string
	StartLine, StartCol int
	EndLine, EndCol     int
	Statements, Count   uint64
}

CoverageBlock describes one source span from a Go coverage profile.

func ParseCoverageBlocks

func ParseCoverageBlocks(r io.Reader) ([]CoverageBlock, error)

ParseCoverageBlocks parses and validates a Go coverage profile, returning every block, including blocks with zero execution count. The input mode is validated even though it does not alter block parsing.

type CoverageFile

type CoverageFile struct {
	File    string
	Percent float64
	Gaps    []CoverageGap
}

CoverageFile contains coverage and gaps for one source file.

type CoverageGap

type CoverageGap struct {
	File                string
	StartLine, StartCol int
	EndLine, EndCol     int
	Statements          uint64
}

CoverageGap describes an uncovered source span.

type CoverageReport

type CoverageReport struct {
	Files          []CoverageFile
	OverallPercent float64
}

CoverageReport contains the parsed coverage profile.

func ParseCoverage

func ParseCoverage(r io.Reader) (CoverageReport, error)

ParseCoverage parses a Go coverage profile from r.

type RaceAccess

type RaceAccess struct {
	Kind        string           `json:"kind"`
	Address     string           `json:"address"`
	GoroutineID int              `json:"goroutine_id"`
	Function    string           `json:"function"`
	Location    finding.Location `json:"location"`
	State       string           `json:"state,omitempty"`
}

RaceAccess describes one access reported by the race detector.

type RaceConflict

type RaceConflict struct {
	Current           RaceAccess   `json:"current"`
	Previous          RaceAccess   `json:"previous"`
	GoroutineCreation []RaceAccess `json:"goroutine_creation"`
}

RaceConflict contains both conflicting accesses and their creation stacks.

type RaceReportOutput

type RaceReportOutput struct {
	Conflicts      []RaceConflict `json:"conflicts"`
	RawBlocksFound int            `json:"raw_blocks_found"`
}

RaceReportOutput contains parsed race conflicts and block counts.

func Parse

func Parse(input string) RaceReportOutput

Parse converts race detector text into one conflict per DATA RACE block.

type Stats

type Stats struct {
	Valid     int
	Malformed int
}

Stats describes decoding outcomes. Malformed is the number of complete input lines that were not valid JSON test events and were skipped.

func DecodeTestJSON

func DecodeTestJSON(r io.Reader, callback func(TestEvent) error) (Stats, error)

DecodeTestJSON decodes newline-delimited go test -json output in bounded memory. Each valid event is delivered immediately, in input order. Complete malformed lines are skipped so incidental stdout cannot hide later events.

type TestEvent

type TestEvent struct {
	Time    time.Time `json:"Time"`
	Action  string    `json:"Action"`
	Package string    `json:"Package"`
	Test    string    `json:"Test,omitempty"`
	Elapsed float64   `json:"Elapsed,omitempty"`
	Output  string    `json:"Output,omitempty"`
}

TestEvent is one event emitted by go test -json.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL