table

package
v0.42.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrAtLeastOneColumn                  = "table.at_least_one_column"
	ErrHeaderWiderThanMaxWidth           = "table.header_wider_than_max_width"
	ErrHeaderMinWidthGreaterThanMaxWidth = "table.header_min_width_greater_than_max_width"
	ErrWrongNumberOfColumns              = "table.wrong_number_of_columns"
)

Variables

This section is empty.

Functions

func ErrorAtLeastOneColumn added in v0.15.0

func ErrorAtLeastOneColumn() error

func ErrorHeaderMinWidthGreaterThanMaxWidth added in v0.15.0

func ErrorHeaderMinWidthGreaterThanMaxWidth(headerTitle string, minWidth int, maxWidth int) error

func ErrorHeaderWiderThanMaxWidth added in v0.15.0

func ErrorHeaderWiderThanMaxWidth(headerTitle string, maxWidth int) error

func ErrorWrongNumberOfColumns added in v0.15.0

func ErrorWrongNumberOfColumns(rowNumber int, actualCols int, expectedCols int) error

Types

type Header struct {
	Title    string
	MaxWidth int // Max width of the text (not including spacing). Items that are longer will be truncated to less than MaxWidth to fit the ellipses. If 0 is provided, it defaults to no max.
	MinWidth int // Min width of the text (not including spacing)
	Hidden   bool
}

type KeyValuePairOpts added in v0.12.0

type KeyValuePairOpts struct {
	Delimiter     *string // default: ":"
	NumSpaces     *int    // default: 1
	RightJustify  *bool   // default: false
	BoldFirstLine *bool   // default: false
	BoldKeys      *bool   // default: false
}

type KeyValuePairs added in v0.12.0

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

func (*KeyValuePairs) Add added in v0.12.0

func (kvs *KeyValuePairs) Add(key interface{}, value interface{})

func (*KeyValuePairs) AddAll added in v0.12.0

func (kvs *KeyValuePairs) AddAll(kvs2 KeyValuePairs)

func (KeyValuePairs) Print added in v0.12.0

func (kvs KeyValuePairs) Print(options ...*KeyValuePairOpts)

func (KeyValuePairs) String added in v0.12.0

func (kvs KeyValuePairs) String(options ...*KeyValuePairOpts) string

type Opts added in v0.13.0

type Opts struct {
	Sort       *bool // default is true
	BoldHeader *bool // default is true
}

type Table

type Table struct {
	Headers []Header
	Rows    [][]interface{}
	Spacing int // Spacing between rows. If 0 is provided, it defaults to 3.
}

func (*Table) FindHeaderByTitle added in v0.16.0

func (t *Table) FindHeaderByTitle(title string) *Header

func (*Table) Format added in v0.13.0

func (t *Table) Format(opts ...*Opts) (string, error)

func (*Table) MustFormat added in v0.13.0

func (t *Table) MustFormat(opts ...*Opts) string

Return the error message as a string

func (*Table) MustPrint added in v0.13.0

func (t *Table) MustPrint(opts ...*Opts)

Prints the error message as a string (if there is an error)

Jump to

Keyboard shortcuts

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