Documentation ¶
Index ¶
- Constants
- type Align
- type Colorer
- type PrintStructuredIter
- type Printer
- func (p *Printer) EndList()
- func (p *Printer) Print(s ...string)
- func (p *Printer) PrintStructured(v any, options StructuredOptions) error
- func (p *Printer) PrintStructuredTableIter(typ reflect.Type, iter PrintStructuredIter, options StructuredOptions) error
- func (p *Printer) Println(s ...string)
- func (p *Printer) Printlnf(s string, v ...any)
- func (p *Printer) StartList()
- type StructuredOptions
- type TableOptions
Constants ¶
const ( AlignDefault Align = tablewriter.ALIGN_DEFAULT AlignCenter = tablewriter.ALIGN_CENTER AlignRight = tablewriter.ALIGN_RIGHT AlignLeft = tablewriter.ALIGN_LEFT )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PrintStructuredIter ¶
type Printer ¶
type Printer struct { // Must always be present Output io.Writer JSON bool // This is unset/empty in JSONL mode JSONIndent string JSONPayloadShorthand bool // Only used for non-JSON, defaults to RFC3339 FormatTime func(time.Time) string // Only used for non-JSON, defaults to color.Magenta TableHeaderColorer Colorer // contains filtered or unexported fields }
func (*Printer) EndList ¶
func (p *Printer) EndList()
Must be called after Printer.StartList or will panic. See Godoc on that function for more details.
func (*Printer) PrintStructured ¶
func (p *Printer) PrintStructured(v any, options StructuredOptions) error
For JSON, if v is a proto message, protojson encoding is used
func (*Printer) PrintStructuredTableIter ¶ added in v1.0.0
func (p *Printer) PrintStructuredTableIter( typ reflect.Type, iter PrintStructuredIter, options StructuredOptions, ) error
Fields must be present for table
func (*Printer) StartList ¶
func (p *Printer) StartList()
When called for JSON with indent, this will create an initial bracket and make sure all Printer.PrintStructured calls get commas properly to appear as a list (but the indention and multiline posture of the JSON remains). When called for JSON without indent, this will make sure all Printer.PrintStructured is on its own line (i.e. JSONL mode). When called for non-JSON, this is a no-op.
Printer.EndList must be called at the end. If this is called twice it will panic. This and the end call are not safe for concurrent use.
type StructuredOptions ¶
type StructuredOptions struct { // Derived if not present. Ignored for JSON printing. Fields []string // Ignored for JSON printing. ExcludeFields []string // If not set, not printed as table in text mode. This is ignored for JSON // printing. Table *TableOptions OverrideJSONPayloadShorthand *bool }