format

package
v0.9.14 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHeaderString

func GetHeaderString(tmpl *template.Template, nameLimit int) string

GetHeaderString extract the set of column names from a template.

func TrimAndPad

func TrimAndPad(s string, l int) string

TrimAndPad modifies `s` so that it is exactly `l` characters long, removing characters from the end, or adding spaces as necessary.

Types

type Format

type Format string

Format defines a type for a string that can be used as template to format data.

func (Format) Execute

func (f Format) Execute(writer io.Writer, withHeaders bool, nameLimit int, data interface{}) error

Execute compiles the template and prints the output

func (Format) ExecuteFixedWidth

func (f Format) ExecuteFixedWidth(columnWidths interface{}, header bool, data interface{}) (string, error)

ExecuteFixedWidth Formats a table row using a set of fixed column widths. Used for streaming output where column widths cannot be automatically determined because only one line of the output is available at a time.

Assumes the format uses tab as a field delimiter.

columnWidths: struct that contains column widths header: If true return the header. If false then evaluate data and return data. data: Data to evaluate

func (Format) IsTable

func (f Format) IsTable() bool

IsTable returns a bool if the template is a table

Jump to

Keyboard shortcuts

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