Documentation ¶
Overview ¶
Package table implements a container API for tables of data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Params ¶
type Params struct { Rows int // max. number of rows to write; 0 = unlimited (default) NoHeader bool // whether to print the header, default - yes MaxColWidth int // for WriteText only; 0 = unlimited, otherwise must be >= 4 }
Params are parameters for pretty-printing or CSV export of Table data.
type Row ¶
type Row interface {
CSV() []string // an encoding/csv compatible row representation
}
Row interface that a table row representation must implement.
type Table ¶
Table container.
A typical use:
type MyRow struct { Name string Age int } func (r MyRow) CSV() []string { return []string{r.Name, fmt.Sprintf("%d", r.Age)} } t := NewTable([]string{"Name", "Age"}) t.AddRow(MyRow{"John", 25}, MyRow{"Jane", 24})
func NewTable ¶
NewTable creates a new Table instance with optional column headers. It is expected that, when present, the number of column headers is the same as the number of elements in each Row.
Click to show internal directories.
Click to hide internal directories.