Documentation
¶
Overview ¶
Package iofmt provides utilities for formatting and outputting structured data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatToJSON ¶
FormatToJSON formats the given data in JSON format.
func FormatToTable ¶
func FormatToTable(io *terminal.IO, l int, header, footer HeaderBuilderFunc, contentRow RowBuilderFunc) error
FormatToTable formats in Table format using the given BuilderFunc's. Header and footer builder functions are optional. The length of the slice must be given.
Types ¶
type Format ¶
type Format uint8
Format is an output format.
func FormatFromString ¶
FormatFromString parses a supported Format from its string representation.
type HeaderBuilderFunc ¶
type HeaderBuilderFunc func(io.Writer, TableRowBuilder)
HeaderBuilderFunc allows building of a tables header by providing a TableRowBuilder and the raw io.Writer for using generic formatting functions like fmt.Fprintf().
type RowBuilderFunc ¶
type RowBuilderFunc func(TableRowBuilder, int)
RowBuilderFunc allows building of a tables content row by providing a TableRowBuilder and the id of the record to format.
type TableRowBuilder ¶
type TableRowBuilder interface { // AddField adds a field with the given string to the row. If given, the // ColorFunc will be used to colorize the resulting field text. AddField(string, terminal.ColorFunc) }
TableRowBuilder provides methods for building table rows. It is a sub-interface of terminal.TablePrinter.