output

package module
v0.3.19 Latest Latest
Warning

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

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

README

Documentation

Overview

Package output encodes a command result to a writer in a selectable format (JSON or YAML). It is CLI-agnostic — it takes a writer, a format, and a value — so a daemon, a CLI, or a test can all reuse the same encoding. It owns the one error intrinsic to its own machinery, declared on the shared sentinel type.

Index

Constants

View Source
const ErrUnsupportedFormat errs.Const = "unsupported output format"

ErrUnsupportedFormat indicates a format the encoder cannot produce.

Variables

This section is empty.

Functions

func Write

func Write(w io.Writer, f Format, data any) error

Write encodes data to w in the requested format, defaulting to JSON when the format is empty, and returning ErrUnsupportedFormat for any unknown format.

Types

type Format

type Format string

Format selects how a result is encoded.

const (
	FormatJSON Format = "json"
	FormatYAML Format = "yaml"
)

FormatJSON and FormatYAML are the supported encodings.

Jump to

Keyboard shortcuts

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