output

package module
v0.3.24 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 4 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址