machine

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package machine encodes a model.Record as the stable JSON/NDJSON wire format described in docs/schema.md. The wire shapes here are a deliberately separate view-model from model.Record's Go-internal shapes (Field[T]'s generic {Value,Sources}, TimeValue's raw {Time,Raw,Parsed}) — this package owns the public API contract, and a breaking change to any shape below must bump SchemaVersion.

Index

Constants

View Source
const SchemaVersion = 1

SchemaVersion is the current machine-output schema version.

Variables

This section is empty.

Functions

func Encode

func Encode(w io.Writer, r model.Record, opts Options) error

Encode writes r as a single compact JSON object followed by a newline.

func EncodeASN added in v0.3.0

func EncodeASN(w io.Writer, r model.ASNRecord, opts Options) error

EncodeASN writes r as a single compact JSON object followed by a newline — the ASN-record counterpart to Encode.

func EncodeASNNDJSON added in v0.3.0

func EncodeASNNDJSON(w io.Writer, r model.ASNRecord, opts Options) error

EncodeASNNDJSON writes r as one compact JSON object followed by a newline — the shape used for -o ndjson multi-target output, one record per line. Mechanically identical to EncodeASN; kept as a separate name so call sites make the multi-target intent explicit.

func EncodeError

func EncodeError(w io.Writer, domainName string, err error) error

EncodeError writes a machine-mode error object to w: {"error": "...", "domain": "..."}. Used for stderr so stdout stays schema-clean even when a lookup fails in machine mode.

func EncodeIP added in v0.2.0

func EncodeIP(w io.Writer, r model.IPRecord, opts Options) error

EncodeIP writes r as a single compact JSON object followed by a newline — the IP-record counterpart to Encode.

func EncodeIPNDJSON added in v0.2.0

func EncodeIPNDJSON(w io.Writer, r model.IPRecord, opts Options) error

EncodeIPNDJSON writes r as one compact JSON object followed by a newline — the shape used for -o ndjson multi-target output, one record per line. Mechanically identical to EncodeIP; kept as a separate name so call sites make the multi-target intent explicit.

func EncodeNDJSON

func EncodeNDJSON(w io.Writer, r model.Record, opts Options) error

EncodeNDJSON writes r as one compact JSON object followed by a newline — the shape used for -o ndjson multi-domain output, one record per line. Mechanically identical to Encode; kept as a separate name so call sites make the multi-domain intent explicit.

Types

type Options

type Options struct {
	// Raw includes each source's raw response payload (sources[].raw).
	Raw bool
}

Options controls what Encode/EncodeNDJSON include.

Jump to

Keyboard shortcuts

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