print

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package print provides helpers for structured output printing.

Index

Constants

View Source
const DefaultIndent = "\t"

DefaultIndent is the default string for one level of indentation.

Variables

This section is empty.

Functions

This section is empty.

Types

type Printer

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

Printer provides convenience methods for structured output printing. Specifically it stores any errors encountered so error checking does not have to be done on every print call. Also provides helpers for managing indentation.

func New

func New(w io.Writer) Printer

New builds a printer writing to w.

func (*Printer) Dedent

func (p *Printer) Dedent()

Dedent by one level.

func (*Printer) Error

func (p *Printer) Error() error

Error returns the first error that occurred so far, if any.

func (*Printer) Indent

func (p *Printer) Indent()

Indent by one level.

func (*Printer) Linef

func (p *Printer) Linef(format string, args ...interface{})

Linef prints a formatted line.

func (*Printer) NL

func (p *Printer) NL()

NL prints a newline.

func (*Printer) Printf

func (p *Printer) Printf(format string, args ...interface{})

Printf prints formatted output.

func (*Printer) SetError

func (p *Printer) SetError(err error)

SetError records a possible error.

func (*Printer) SetIndentString

func (p *Printer) SetIndentString(indent string)

SetIndentString configures the string used for one level of indentation.

type TabWriter

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

TabWriter provides tabwriter.Writer functionality with the Printer interface.

func NewTabWriter

func NewTabWriter(w io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *TabWriter

NewTabWriter builds a TabWriter. Arguments are the same as for tabwriter.NewWriter.

func (*TabWriter) Flush

func (p *TabWriter) Flush()

Flush the tabwriter.

Jump to

Keyboard shortcuts

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