table

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintRow

func PrintRow(p *Printer, row interface{})

PrintRow uses reflection to print each row.

Types

type Col

type Col struct {
	Name       string
	Width      int
	FixedWidth bool
}

Col contains printer column information.

type PrintRowFunc

type PrintRowFunc func(p *Printer, row interface{})

PrintRowFunc is a custom function called to print each table row.

type Printer

type Printer struct {
	*bufio.Writer

	Cols   []Col
	ColSep string
	// contains filtered or unexported fields
}

Printer outputs data in a table format.

func NewPrinter

func NewPrinter(v interface{}) *Printer

NewPrinter creates a table layout printer for v. The only currently supported data type is a slice of struct pointers.

func (*Printer) Print

func (p *Printer) Print(w io.Writer, fn PrintRowFunc)

Print outputs printer data to w. If fn is specified, it is called to print each row.

func (*Printer) PrintCol

func (p *Printer) PrintCol(i int, s string, more bool)

PrintCol prints s as the ith column, adding padding and column separator if more is true.

func (*Printer) PrintErr

func (p *Printer) PrintErr(e string)

PrintErr prints error string e as the last column in the current row.

type RowPrinter

type RowPrinter interface {
	PrintRow(p *Printer)
}

RowPrinter may be implemented by the type being printed to control its own output.

Jump to

Keyboard shortcuts

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