Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type TabPrinter ¶
type TabPrinter struct {
// contains filtered or unexported fields
}
TabPrinter represents a printer that uses tab separation
func NewTab ¶
func NewTab(w io.Writer) *TabPrinter
NewTab creates a printer for tab separated values
func (*TabPrinter) Print ¶
func (p *TabPrinter) Print(elems interface{}, fields []string)
Print can be used to print a some fields of a struct slice, all tab separated. The `fields` slice should contain the names of the struct fields that should be printed. If a field does not exist in a given element of `elems`, it will panic If `elems` is not of a slice type, nothing will be printed.
func (*TabPrinter) PrintWithHeaders ¶
func (p *TabPrinter) PrintWithHeaders(elems interface{}, fields []string, headers []string)
PrintWitHeaders prints using Print but with an additional header line Each element of the `headers` slice will be used to name a given tab-separated column `headers` and `fields` should be match one to one i.e. for each header there should be a field `fields` can be either a direct struct field or a method that takes no arguments and returns a single value If the `field` is a method, it should contain the `()` suffix string Examples: PrintWithHeaders(elems, []string{"Name", "Price"}, []string{"NAME","PRICE"}) PrintWithHeaders(elems, []string{"GetName()", "GetPrice()"}, []string{"NAME","PRICE"})