tableprinter

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Overview

Package tableprinter implements a pretty printer that writes rows and columns as a formatted table.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnGetter

type ColumnGetter func(row interface{}) string

A ColumnGetter returns the selected ColumnGetter value of a row.

type Printer

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

A Printer is a formatter for writing tables.

The header of the table is written by formatting the column names. The body of the table is written by formatting each row using the selected columns in the given order.

func New

func New(tw *tabwriter.Writer, cgetters map[string]ColumnGetter, sorted, includeHeader, includeHeaderSeparator bool) *Printer

New returns a new Printer backed by the given writers. The ColumnGetters are used to select the columns from a row.

func (*Printer) Print

func (p *Printer) Print(columns []string, rows []interface{}) error

Print writes the rows as a table, selecting on the specified column names.

Jump to

Keyboard shortcuts

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