Documentation
¶
Overview ¶
Package table implements a row-based data set that can the printed with a header and space aligned columns. The text output looks like a spreadsheet.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotStruct = errors.New("not a struct")
ErrNotStruct is returned from a Table's Write method if the argument is not a struct.
Functions ¶
func WithColor ¶
WithColor is an option setting function for New. It replaces the default set of Colors with c.
func WithLabelFunction ¶
WithLableFunction is an option setting function for New. This function convert struct field names into text header labels. The default behavior is to convert the CamelCase field names into UPPER_CASE labels. The "table" struct tags can be used to override this.
func WithWriter ¶
WithWriter is an option setting function for New. It replaces the default io.Writer with w. The io.Writer is used for all Table output.
Types ¶
type Colors ¶
type Colors struct { Header []sgr.Param EvenRow []sgr.Param OddRow []sgr.Param Empty []sgr.Param Repeat []sgr.Param }
Colors is the set styles/colors to be applied to Table elements.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table holds a slice of structs that can be Flush()ed as a Text table, or encoded as JSON or YAML.
func New ¶
New returns a new Table. The default settings can be overridden using the With* options setting functions. For example: WithColors() can be used to replace the default coloring scheme.
func (*Table) FlushText ¶
func (t *Table) FlushText()
FlushText flushes the Table data to its io.Writer as column aligned ANSI styled text. If the io.Writer is not a terminal no ANSI styles will be applied.
Directories
¶
Path | Synopsis |
---|---|
Package main shows some features of the table package.
|
Package main shows some features of the table package. |
Package sgr is a minimalist package for setting ANSI color terminal escape sequences.
|
Package sgr is a minimalist package for setting ANSI color terminal escape sequences. |
color
Package color provides default foreground and background color convenience variables.
|
Package color provides default foreground and background color convenience variables. |