Documentation
¶
Index ¶
- type Alignment
- type Table
- func (t *Table) AddColumn(field string, column []any) error
- func (t *Table) AddRow(row []any) error
- func (t *Table) Clear()
- func (t *Table) ClearRows()
- func (t *Table) DelColumn(field string) error
- func (t *Table) DelRow(index int) error
- func (t *Table) FieldNames() []string
- func (t *Table) GetFormattedString(format string) string
- func (t *Table) RenderASCII() string
- func (t *Table) RenderCSV() string
- func (t *Table) RenderHTML() string
- func (t *Table) RenderJSON() string
- func (t *Table) RenderLaTeX() string
- func (t *Table) RenderMarkdown() string
- func (t *Table) RenderMediaWiki() string
- func (t *Table) RenderText() string
- func (t *Table) RenderUnicode() string
- func (t *Table) SetAlign(field string, align Alignment)
- func (t *Table) SetAlignAll(align Alignment)
- func (t *Table) SetFieldNames(fields []string)
- func (t *Table) SetRowFilter(filter func([]any) bool)
- func (t *Table) SetSortBy(field string, reverse bool)
- func (t *Table) SetStyle(style TableStyle)
- func (t *Table) String() string
- type TableStyle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents a table with field names and rows Only ASCII rendering is implemented for now
func FromDBRows ¶
FromDBRows creates a Table from a *sql.Rows result set.
func NewTableWithFields ¶
NewTableWithFields creates a new table with field names
func (*Table) AddColumn ¶
AddColumn adds a column to the table with the given field name and column data.
func (*Table) ClearRows ¶
func (t *Table) ClearRows()
ClearRows deletes all rows but keeps field names.
func (*Table) GetFormattedString ¶
GetFormattedString returns the table as a string in the specified format. Supported formats: "text", "ascii", "csv", "json", "html", "latex", "mediawiki", "markdown"
func (*Table) RenderASCII ¶
RenderASCII renders the table as an ASCII string
func (*Table) RenderHTML ¶
RenderHTML renders the table as an HTML table
func (*Table) RenderJSON ¶
RenderJSON renders the table as JSON array of objects
func (*Table) RenderLaTeX ¶
RenderLaTeX renders the table as LaTeX tabular
func (*Table) RenderMarkdown ¶
RenderMarkdown renders the table as GitHub-flavored Markdown
func (*Table) RenderMediaWiki ¶
RenderMediaWiki renders the table as MediaWiki markup
func (*Table) RenderText ¶
RenderText renders the table as plain text (same as ASCII)
func (*Table) RenderUnicode ¶
RenderUnicode renders the table using Unicode box-drawing characters
func (*Table) SetAlignAll ¶
SetAlignAll sets the alignment for all columns.
func (*Table) SetFieldNames ¶
SetFieldNames sets the field (column) names
func (*Table) SetRowFilter ¶
SetRowFilter sets a filter function for rows.
func (*Table) SetStyle ¶
func (t *Table) SetStyle(style TableStyle)
SetStyle sets the table style options
type TableStyle ¶
type TableStyle struct {
Border bool
PreserveInternalBorder bool
Header bool
HRule string // "FRAME", "HEADER", "ALL", "NONE"
VRule string // "FRAME", "ALL", "NONE"
IntFormat string // e.g. ",d" or "03d"
FloatFormat string // e.g. ".2f"
CustomFormat map[string]func(field string, value any) string
PaddingWidth int
LeftPaddingWidth int
RightPaddingWidth int
VerticalChar string
HorizontalChar string
HorizontalAlignChar string
JunctionChar string
TopJunctionChar string
BottomJunctionChar string
RightJunctionChar string
LeftJunctionChar string
TopRightJunctionChar string
TopLeftJunctionChar string
BottomRightJunctionChar string
BottomLeftJunctionChar string
MinTableWidth int
MaxTableWidth int
MaxWidth int
MinWidth int
UseHeaderWidth *bool
BreakOnHyphens *bool
}
TableStyle holds options for customizing table appearance All fields are optional; zero values mean default behavior