table

package
v0.5.1-0...-faa3f61 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Header string
	Width  int
	// If false, render this column.
	Hide bool
	// If true, set the width to the widest value in this column.
	Flexible  bool
	LeftAlign bool
}

Column represents metadata about a column in a table.

func NewColumn

func NewColumn(header string) Column

NewColumn creates a new flexible column with the given name.

func (Column) WithLeftAlign

func (c Column) WithLeftAlign() Column

WithLeftAlign turns on the left align of this column and returns it.

type Row

type Row = []string

Row is a single row of data in a table.

type Table

type Table struct {
	Columns       []Column
	Data          []Row
	Sort          []int
	ColumnSpacing string
}

Table represents a table of data to be rendered.

func NewTable

func NewTable(cols []Column, data []Row) Table

NewTable creates a new table with the given columns and rows.

func (*Table) Render

func (t *Table) Render(w io.Writer)

Render writes the full table to the given Writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL