Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatEntity ¶
FormatEntity returns a formatted string from the supplied entity title and table of attributes.
func GetEntityPadding ¶
GetEntityPadding will determine the minimum width necessary to display the entity attributes.
Types ¶
type EntityFormatter ¶
type EntityFormatter struct { Separator string // contains filtered or unexported fields }
EntityFormatter can be used for neatly displaying attributes of a single entity.
func NewEntityFormatter ¶
func NewEntityFormatter(title string, padWidth int) *EntityFormatter
NewEntityFormatter returns an initialized EntityFormatter.
func (*EntityFormatter) Format ¶
func (f *EntityFormatter) Format(table []TableRow) string
Format generates an output string for the supplied table rows. It includes a single subject header, and each row is printed as an attribute/value pair.
func (*EntityFormatter) Init ¶
func (f *EntityFormatter) Init(padWidth int)
Init instantiates internal variables.
type ErrWriter ¶
type ErrWriter struct { Err error // contains filtered or unexported fields }
ErrWriter eliminates repetitive error handling by capturing an error and ignoring subsequent writes. The original error is available to be used by the caller.
https://dave.cheney.net/2019/01/27/eliminate-error-handling-by-eliminating-errors
func NewErrWriter ¶
NewErrWriter returns an initialized ErrWriter.
type IndentWriter ¶
type IndentWriter struct {
// contains filtered or unexported fields
}
IndentWriter indents every line written to it.
func NewIndentWriter ¶
func NewIndentWriter(w io.Writer, opts ...IndentWriterOption) *IndentWriter
NewIndentWriter returns an initialized IndentWriter.
type IndentWriterOption ¶
type IndentWriterOption func(*IndentWriter)
IndentWriterOption configures the IndentWriter.
func WithPadCount ¶
func WithPadCount(count uint) IndentWriterOption
WithPadCount sets the indent width.
type TableFormatter ¶
type TableFormatter struct {
// contains filtered or unexported fields
}
TableFormatter is a structure that formats string output for a table with labeled columns.
func NewTableFormatter ¶
func NewTableFormatter(columnTitles ...string) *TableFormatter
NewTableFormatter creates and instantiates a new TableFormatter.
func (*TableFormatter) Format ¶
func (t *TableFormatter) Format(table []TableRow) string
Format generates an output string for the set of table rows provided. It includes a header with column titles, and fills only the requested columns in order.
func (*TableFormatter) InitWriter ¶
func (t *TableFormatter) InitWriter(w io.Writer)
InitWriter optionally sets up the tabwriter to use the supplied io.Writer instead of the internal buffer.
func (*TableFormatter) SetColumnTitles ¶
func (t *TableFormatter) SetColumnTitles(c ...string)
SetColumnTitles sets the ordered column titles for the table.