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 ¶
FormatJSON formats the target as a JSON representation.
func FormatShort ¶
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
FormatText formats the target as a text representation. It uses the field name as the key and the field value as the value.
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.