Documentation
¶
Overview ¶
Package table formats an ASCII/ANSI table with dynamic column widths.
Index ¶
Constants ¶
const ( // The cell has been padded Padded = 1 << iota // The cell has been truncated Truncated )
Variables ¶
This section is empty.
Functions ¶
func Fmt ¶
Fmt formats the given rows into a pretty table and returns the string ready to be printed. The fmt parameter is a string of "l" and "r" characters indicating the requested alignment of each column. Example:
rows := [][]string{{"NAME", "VALUE"}, {"Test", "4.5"}, {"Other", "13.2"}} tab := table.Fmt("lr", rows) fmt.Println(tab)
Types ¶
type Formatter ¶
A Formatter is called to apply string formatting such as ANSI escape sequences just before printing a cell. The parameters are the cell text (after padding or truncation), the row and column index (zero based) and a set of flags. possible flags are Padded (the cell has been space padded on the right or left) and Truncated (the cell has been truncated on the right). The returned string must have unchanged (visible) length.
Notes ¶
Bugs ¶
When there are multibyte UTF-8 characters we cut the string shorter than necessary.