Documentation
¶
Overview ¶
Package tablewriter provides a basic ASCII table writer with customization options for: headers, label columns, cell alignment, handling overly-wide cells (truncate vs wrap), and auto-merging repeat values in the same column.
Index ¶
- func ChangeDefaults(defaults Defaults)
- type Alignment
- type Defaults
- type Table
- func (tbl *Table) AppendHeaderRow(row []string) error
- func (tbl *Table) AppendRow(row []string) error
- func (tbl *Table) AppendRows(rows [][]string) error
- func (tbl *Table) DisableHeaderAutoCentering()
- func (tbl *Table) MergeRepeats()
- func (tbl *Table) Render() error
- func (tbl *Table) SetAlignment(alignment Alignment)
- func (tbl *Table) SetLabelLevelCount(n int)
- func (tbl *Table) TruncateWideCells()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChangeDefaults ¶ added in v0.2.0
func ChangeDefaults(defaults Defaults)
ChangeDefaults changes the library's global variable settings for any field supplied. Fields with unsupported changes are ignored.
Types ¶
type Defaults ¶ added in v0.2.0
type Defaults struct {
DividingEdge, DividingLabelEdge, BorderFiller, HeaderFiller string
ContentEdge, LabelEdge string
MaxColWidth int
}
Defaults may be supplied to ChangeDefaults() to change the library's global variable settings. All edge and filler symbols must be 1-rune wide, except for label edges which must be 2-runes wide. MaxColWidth must be > 0. Unsupported field values are ignored.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
A Table can be rendered into a stringified representation of content rows and dividing rows with the results written into an io.Writer.
func (*Table) AppendHeaderRow ¶
AppendHeaderRow appends a header row to the table.
func (*Table) AppendRows ¶
AppendRows appends one or more non-header rows to the table.
func (*Table) DisableHeaderAutoCentering ¶ added in v0.2.0
func (tbl *Table) DisableHeaderAutoCentering()
DisableHeaderAutoCentering causes header cells to be aligned based on the underlying table alignment (default: headers are auto-centered).
func (*Table) MergeRepeats ¶ added in v0.1.2
func (tbl *Table) MergeRepeats()
MergeRepeats merges all repeated values in a column together.
func (*Table) Render ¶
Render creates a stringified representation of content rows and dividing rows and writes the results into the table's io.Writer.
func (*Table) SetAlignment ¶ added in v0.1.3
SetAlignment sets the alignment of cells in content rows to `alignment`.
func (*Table) SetLabelLevelCount ¶ added in v0.1.4
SetLabelLevelCount sets the number of label levels to `n`.
func (*Table) TruncateWideCells ¶ added in v0.1.2
func (tbl *Table) TruncateWideCells()
TruncateWideCells handles overly wide cells by truncating them (default: wrap cell remainder onto new one or more new lines).