format

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSON

func JSON(w io.Writer, value any) error

func MarshalYAML added in v0.3.3

func MarshalYAML(value any) ([]byte, error)

MarshalYAML returns value encoded as YAML indented by 2 spaces. It is the only go.yaml.in/yaml/v3 encoder in drydock (a forbidigo rule keeps it that way). The width is not only style: at yaml.v3's default of 4, a block scalar inside a sequence item whose text starts with a newline or a space gets an indentation indicator that disagrees with the column its content is written at. Parsers reject such a document, or, when every line starts with the same spaces, silently read the text back without them.

func Name

func Name(w io.Writer, names []string) error

func Table

func Table(w io.Writer, columns []Column, rows []map[string]string) error

func YAML

func YAML(w io.Writer, value any) error

YAML writes value as YAML (see MarshalYAML) in a single write, so an encoding error leaves nothing behind and large documents do not reach w in yaml.v3's 128-byte flushes.

func YAMLMulti

func YAMLMulti(w io.Writer, values []any) error

Types

type Column

type Column struct {
	Header string
	Key    string
}

type Output

type Output string
const (
	OutputTable Output = "table"
	OutputYAML  Output = "yaml"
	OutputJSON  Output = "json"
	OutputName  Output = "name"
)

func ParseOutput

func ParseOutput(value string) (Output, error)

Jump to

Keyboard shortcuts

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