runner

package
v0.0.0-...-7ff6432 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package runner wraps goawk: parse a source program, execute it against a set of input files, and stream both stdout output and structured trace events to a callback.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, req Request, emit func(Event))

Types

type Event

type Event struct {
	Kind string `json:"kind"`

	// stdout/stderr/error
	Data string `json:"data,omitempty"`

	// record
	Filename string `json:"filename,omitempty"`
	FNR      int    `json:"fnr,omitempty"`
	NR       int    `json:"nr,omitempty"`
	Line     string `json:"line,omitempty"`

	// pattern / action-start / action-end. Block is intentionally not
	// omitempty because block 0 is a valid (and common) value.
	Block   int  `json:"block"`
	Matched bool `json:"matched,omitempty"`

	// done
	Code int `json:"code,omitempty"`
}

Event is emitted by Run. Kind names match the wire protocol and the trace-hook hooks in goawkviz:

"stdout"        — a line written by the awk program
"stderr"        — a line written to error output
"record"        — a new input record entered the pipeline
"pattern"       — a pattern-action block's pattern was evaluated
"action-start" — an action whose pattern matched began executing
"action-end"   — that action finished executing
"done"          — execution finished, Code is the exit status
"error"         — execution aborted, Data is the error message

type Request

type Request struct {
	Source            string
	Inputs            []string
	Vars              []string
	MaxRecordsPerFile int
}

Jump to

Keyboard shortcuts

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