encode

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package encode serialises an extracted data tree into one of the supported wire formats. JSON, YAML, and msgpack are equivalent projections of the same tree; a Lua encoder is deferred (plan 166) but would slot in behind the same Format enum.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(f Format, v any) ([]byte, error)

Encode serialises v in the requested format. JSON is indented two spaces and newline-terminated for human-readable CLI output; YAML uses a two-space indent; msgpack is the canonical binary form.

Types

type Format

type Format string

Format names a supported output encoding.

const (
	JSON    Format = "json"
	YAML    Format = "yaml"
	Msgpack Format = "msgpack"
)

Supported formats.

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat maps a CLI `--format` value to a Format. The error lists the accepted values so the caller can surface a clear message.

Jump to

Keyboard shortcuts

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