Documentation ¶
Index ¶
- Variables
- type Line
- type Row
- type TableFormat
- type Tabulate
- func (t *Tabulate) Render(format ...interface{}) string
- func (t *Tabulate) SetAlign(align string)
- func (t *Tabulate) SetEmptyString(empty string)
- func (t *Tabulate) SetFloatFormat(format byte) *Tabulate
- func (t *Tabulate) SetHeaders(headers []string) *Tabulate
- func (t *Tabulate) SetHideLines(hide []string)
- func (t *Tabulate) SetMaxCellSize(max int)
- func (t *Tabulate) SetSplitConcat(r string)
- func (t *Tabulate) SetTitle(title ...string) *Tabulate
- func (t *Tabulate) SetWrapDelimiter(r rune)
- func (t *Tabulate) SetWrapStrings(wrap bool)
- type TabulateRow
Constants ¶
This section is empty.
Variables ¶
var MIN_PADDING = 5
Minimum padding that will be applied
var TableFormats = map[string]TableFormat{ "simple": { LineTop: Line{"", "-", " ", ""}, LineBelowHeader: Line{"", "-", " ", ""}, LineBottom: Line{"", "-", " ", ""}, HeaderRow: Row{"", " ", ""}, DataRow: Row{"", " ", ""}, TitleRow: Row{"", " ", ""}, Padding: 1, }, "plain": { HeaderRow: Row{"", " ", ""}, DataRow: Row{"", " ", ""}, TitleRow: Row{"", " ", ""}, Padding: 1, }, "grid": { LineTop: Line{"+", "-", "+", "+"}, LineBelowHeader: Line{"+", "=", "+", "+"}, LineBetweenRows: Line{"+", "-", "+", "+"}, LineBottom: Line{"+", "-", "+", "+"}, HeaderRow: Row{"|", "|", "|"}, DataRow: Row{"|", "|", "|"}, TitleRow: Row{"|", " ", "|"}, Padding: 1, }, }
Table Formats that are available to the user The user can define his own format, just by adding an entry to this map and calling it with Render function e.g t.Render("customFormat")
Functions ¶
This section is empty.
Types ¶
type TableFormat ¶
type TableFormat struct { LineTop Line LineBelowHeader Line LineBetweenRows Line LineBottom Line HeaderRow Row DataRow Row TitleRow Row Padding int HeaderHide bool FitScreen bool }
Basic Structure of TableFormat
type Tabulate ¶
type Tabulate struct { Data []*TabulateRow Title string TitleAlign string Headers []string FloatFormat byte TableFormat TableFormat Align string EmptyVar string HideLines []string MaxSize int WrapStrings bool WrapDelimiter rune SplitConcat string }
Main Tabulate structure
func Create ¶
func Create(data interface{}) *Tabulate
Create a new Tabulate Object Accepts 2D String Array, 2D Int Array, 2D Int64 Array, 2D Bool Array, 2D Float64 Array, 2D interface{} Array, Map map[strig]string, Map map[string]interface{},
func (*Tabulate) SetEmptyString ¶
Set how an empty cell will be represented
func (*Tabulate) SetFloatFormat ¶
Set Float Formatting will be used in strconv.FormatFloat(element, format, -1, 64)
func (*Tabulate) SetHeaders ¶
Set Headers of the table If Headers count is less than the data row count, the headers will be padded to the right
func (*Tabulate) SetHideLines ¶
Set which lines to hide. Can be: top - Top line of the table, belowheader - Line below the header, bottom - Bottom line of the table
func (*Tabulate) SetMaxCellSize ¶
Sets the maximum size of cell If WrapStrings is set to true, then the string inside the cell will be split up into multiple cell
func (*Tabulate) SetSplitConcat ¶
SetSplitConcat assigns the character that will be used when a WrapDelimiter is set but the renderer cannot abide by the desired split. This may happen when the WrapDelimiter is a space ' ' but a single word is longer than the width of a cell
func (*Tabulate) SetTitle ¶
SetTitle sets the title of the table can also accept a second string to define an alignment for the title
func (*Tabulate) SetWrapDelimiter ¶
SetWrapDelimiter assigns the character ina string that the rednderer will attempt to split strings on when a cell must be wrapped
func (*Tabulate) SetWrapStrings ¶
type TabulateRow ¶
Represents normalized tabulate Row