formatter

package
v0.1.26 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package formatter provides functions to format data structures into different output formats such as YAML, JSON, and text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(writer io.Writer, target any, t FormatType) error

Format formats the target as a YAML, JSON, or text representation. It's a convenience function that wraps the specific format functions.

func FormatJSON

func FormatJSON(writer io.Writer, target any) error

FormatJSON formats the target as a JSON representation.

func FormatShort

func FormatShort(w io.Writer, data any) error

FormatShort formats the target struct to a short text representation. If the field has a "short" tag, it uses the value of that tag as the key.

func FormatText added in v0.1.18

func FormatText(w io.Writer, data any) error

FormatText formats the target as a text representation. It uses the field name as the key and the field value as the value.

func FormatYAML

func FormatYAML(writer io.Writer, target any) error

FormatYAML formats the target as a YAML representation.

Types

type FormatType

type FormatType string

FormatType represents the type of format to be used for output.

const (
	YAML  FormatType = "yaml"
	JSON  FormatType = "json"
	TEXT  FormatType = "text"
	SHORT FormatType = "short"
)

Format types.

Jump to

Keyboard shortcuts

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