output

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter interface {
	// Format writes v to the output stream.
	Format(w io.Writer, v any) error
	// FormatError writes a structured error to the output stream.
	FormatError(w io.Writer, code string, message string, hint string) error
}

Formatter renders structured data to an output stream.

func New

func New(format string) Formatter

New returns a Formatter for the given format name ("json" or "text").

type JSONFormatter

type JSONFormatter struct{}

JSONFormatter outputs data as indented JSON.

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(w io.Writer, v any) error

func (*JSONFormatter) FormatError

func (f *JSONFormatter) FormatError(w io.Writer, code string, message string, hint string) error

type TextFormatter

type TextFormatter struct{}

TextFormatter outputs data as human-readable text.

func (*TextFormatter) Format

func (f *TextFormatter) Format(w io.Writer, v any) error

func (*TextFormatter) FormatError

func (f *TextFormatter) FormatError(w io.Writer, code string, message string, hint string) error

Jump to

Keyboard shortcuts

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