Documentation ¶
Index ¶
Constants ¶
const ( // CSVFormat sets output format to comma-separated values CSVFormat = "csv" // TableFormat sets output format to an ASCII table TableFormat = "table" // TextFormat sets the output format to a fmt-renderd text string TextFormat = "text" )
Variables ¶
var AllFormats = []string{CSVFormat, TableFormat, TextFormat}
AllFormats contains all the formats supported
Functions ¶
This section is empty.
Types ¶
type BasicFormatter ¶
type BasicFormatter struct {
FmtString string
}
BasicFormatter uses fmt.Sprintf to format based on a static format string
func (BasicFormatter) Format ¶
func (bf BasicFormatter) Format(value string) string
Format formats value by applying format with fmt.Sprintf
type Formatter ¶
type Formatter interface { // Format formats as source string into a new string Format(string) string }
Formatter is a dumb way to inject custom formatting logic for column data. This can be useful for outputting prefix/suffixes or other basic translations
type FuncFormatter ¶
FuncFormatter wraps a user-defined function to apply formatting
func (FuncFormatter) Format ¶
func (ff FuncFormatter) Format(value string) string
Format formats the value by calling the external function
type Option ¶
type Option func(*Writer)
Option modifies default options of the Writer
func WithFormatter ¶
WithFormatter sets the text formatting for the column
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer writes structured data to an internal buffer and outputs it as a given format when flushed
func New ¶
New returns a new Writer for writing. Format should be one of AllFormats. The size value determines how big the internal buffer should be. When the buffer fills, the writer automatically flushes it.
Directories ¶
Path | Synopsis |
---|---|
example
|
|
formatters
package main is an example program to demonstrate how to use custom column formatters.
|
package main is an example program to demonstrate how to use custom column formatters. |