tablewriter

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Overview

Package tablewriter provides a basic ASCII table writer with customization options for: headers, label columns, cell alignment, handling overly-wide cells (truncate vs wrap), and auto-merging repeat values in the same column.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetContentEdge

func SetContentEdge(symbol string)

SetContentEdge sets the edge symbol in content rows to `symbol` (default: "|")

func SetDividingEdge

func SetDividingEdge(symbol string)

SetDividingEdge sets the edge symbol in dividing rows to `symbol` (default: "+")

func SetDividingFiller

func SetDividingFiller(symbol string)

SetDividingFiller sets the symbol that creates space between dividing edges to `symbol` (default: "-")

func SetDividingLabelEdge

func SetDividingLabelEdge(symbol string)

SetDividingLabelEdge sets the edge symbol that demarcates the end of the label levels in dividing rows to `symbol` (default: "++")

func SetLabelEdge

func SetLabelEdge(symbol string)

SetLabelEdge sets the edge symbol that demarcates the end of the label levels in content rows to `symbol` (default: "||")

Types

type Alignment

type Alignment int

An Alignment configures how text is aligned in a cell.

const (
	// AlignCenter centers the cell.
	AlignCenter Alignment = iota
	// AlignRight right-justifies the cell
	AlignRight
	// AlignLeft left-justifies the cell
	AlignLeft
)

type Table

type Table struct {
	// contains filtered or unexported fields
}

A Table can be rendered into a stringified representation of content rows and dividing rows with the results written into an io.Writer.

func NewTable

func NewTable(w io.Writer) *Table

NewTable creates a default table writing to `w`.

func (*Table) AppendHeaderRow

func (tbl *Table) AppendHeaderRow(row []string) error

AppendHeaderRow appends a header row to the table.

func (*Table) AppendRow

func (tbl *Table) AppendRow(row []string) error

AppendRow appends a non-header row to the table.

func (*Table) AppendRows

func (tbl *Table) AppendRows(rows [][]string) error

AppendRows appends one or more non-header rows to the table.

func (*Table) MergeRepeats added in v0.1.2

func (tbl *Table) MergeRepeats()

MergeRepeats merges all repeated values in a column together.

func (*Table) Render

func (tbl *Table) Render() error

Render creates a stringified representation of content rows and dividing rows and writes the results into the table's io.Writer.

func (*Table) TruncateWideCells added in v0.1.2

func (tbl *Table) TruncateWideCells()

TruncateWideCells handles overly wide cells by truncating them (default: wrap cell remainder onto new one or more new lines).

Jump to

Keyboard shortcuts

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