Documentation
¶
Overview ¶
Package table contains methods and structs for rendering data as a table
Index ¶
- Constants
- Variables
- type Table
- func (t *Table) Add(data ...interface{}) *Table
- func (t *Table) HasData() bool
- func (t *Table) Print(data ...interface{}) *Table
- func (t *Table) Render() *Table
- func (t *Table) RenderHeaders()
- func (t *Table) Separator() *Table
- func (t *Table) SetAlignments(align ...uint8) *Table
- func (t *Table) SetHeaders(headers ...string) *Table
- func (t *Table) SetSizes(sizes ...int) *Table
Examples ¶
Constants ¶
View Source
const ( ALIGN_LEFT uint8 = 0 ALIGN_CENTER = 1 ALIGN_RIGHT = 2 )
Column alignment flags
Variables ¶
View Source
var ColumnSeparatorSymbol = "|"
ColumnSeparatorSymbol is column separator symbol
View Source
var HeaderCapitalize = false
HeaderCapitalize is flag for capitalizing headers by default
View Source
var HeaderColorTag = "{*}"
HeaderColorTag is fmtc tag used for headers by default for all tables
View Source
var MaxWidth = 0
MaxWidth is a maximum table width
View Source
var SeparatorSymbol = "-"
SeparatorSymbol used for separator generation
Functions ¶
This section is empty.
Types ¶
type Table ¶
type Table struct { Sizes []int // Custom columns sizes Headers []string // Slice with headers Alignment []uint8 // Columns alignment // contains filtered or unexported fields }
Table is struct which can be used for table rendering
func NewTable ¶
NewTable creates new table struct
Example ¶
t := NewTable() t.SetHeaders("id", "user", "balance") t.SetSizes(4, 12) t.SetAlignments(ALIGN_RIGHT, ALIGN_RIGHT, ALIGN_LEFT) t.Add(1, "{g}Bob{!}", 1.42) t.Add(2, "John", 73.1) t.Add(3, "Mary", 2.29) t.Render()
Output:
func (*Table) SetAlignments ¶
SetAlignments sets aligment of columns
func (*Table) SetHeaders ¶
SetHeaders sets headers
Click to show internal directories.
Click to hide internal directories.