Documentation
¶
Index ¶
- Constants
- func AlignText(text string, width int, alignment int) string
- func CsvSplit(data string) []string
- type Table
- func (t *Table) AddCSVRow(items string) error
- func (t *Table) AddRow(row []string) error
- func (t *Table) AddRowItems(items ...interface{}) error
- func (t *Table) Column(name string) (int, bool)
- func (t *Table) FormatJSON() string
- func (t *Table) FormatText() []string
- func (t *Table) GetHeadings() []string
- func (t *Table) Print(format string) error
- func (t *Table) RowLimit(limit int) *Table
- func (t *Table) SetAlignment(column int, alignment int) error
- func (t *Table) SetColumnOrder(order []int) error
- func (t *Table) SetColumnOrderByName(order []string) error
- func (t *Table) SetIndent(s int) error
- func (t *Table) SetMinimumWidth(n int, w int) error
- func (t *Table) SetOrderBy(name string) error
- func (t *Table) SetPagination(height, width int)
- func (t *Table) SetSpacing(s int) error
- func (t *Table) SetStartingRow(s int) error
- func (t *Table) SetWhere(clause string) *Table
- func (t *Table) ShowHeadings(flag bool) *Table
- func (t *Table) ShowRowNumbers(flag bool) *Table
- func (t *Table) ShowUnderlines(flag bool) *Table
- func (t *Table) SortRows(column int, ascending bool) error
- func (t *Table) String(format string) (string, error)
Constants ¶
const ( // AlignmentLeft aligns the column to the left. AlignmentLeft = -1 // AlignmentRight aligns the column to the right. AlignmentRight = 1 // AlignmentCenter aligns the column to the center. AlignmentCenter = 0 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is the wrapper object around a table to be printed.
func NewCSV ¶
NewCSV creates a new table using a single string with comma-separated heading names. These typically correspond to the first row in a CSV data file.
func (*Table) AddCSVRow ¶
AddCSVRow addsa row to an existing table, where the row is expressed as a string with comma-separated values.
func (*Table) AddRow ¶
AddRow adds a row to an existing table using an array of string objects, where each object represents a column of the data.
func (*Table) AddRowItems ¶
AddRowItems adds a row to an existing table using individual parameters. Each parameter is converted to a string representation, and the set of all formatted values are added to the table as a row.
func (*Table) Column ¶
Column returns the column number for a named column. The boolean return value indicates if the value was found, if true then the integer result is a zero-based column number.
func (*Table) FormatJSON ¶
FormatJSON will produce the text of the table as JSON.
func (*Table) FormatText ¶
FormatText will output a table using current rows and format specifications.
func (*Table) GetHeadings ¶
GetHeadings returns an array of the headings already stored in the table. This can be used to validate a name against the list of headings, for example.
func (*Table) SetAlignment ¶
SetAlignment sets the alignment for a given column. Column numbers are zero-based.
func (*Table) SetColumnOrder ¶
SetColumnOrder accepts a list of column positions and uses it to set the order in which columns of output are printed.
func (*Table) SetColumnOrderByName ¶
SetColumnOrderByName accepts a list of column positions and uses it to set the order in which columns of output are printed.
func (*Table) SetMinimumWidth ¶
SetMinimumWidth specifies the minimum width of a column. The column number is always zero-based.
func (*Table) SetOrderBy ¶
SetOrderBy sets the name of the column that should be used for sorting the output data.
func (*Table) SetPagination ¶
func (*Table) SetSpacing ¶
SetSpacing specifies the spaces between columns in output.
func (*Table) SetStartingRow ¶
SetStartingRow specifies the first row of the table to be printed. A value less than zero is an error.
func (*Table) SetWhere ¶
SetWhere sets an expression to be used as a "where" clause to select table rows.
func (*Table) ShowHeadings ¶
ShowHeadings disables printing of column headings when the parameter is true.
func (*Table) ShowRowNumbers ¶
ShowRowNumbers enables printing of column headings when the parameter is true.
func (*Table) ShowUnderlines ¶
ShowUnderlines enables underlining of column headings when the parameter is true.