printer

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FieldMap

func FieldMap(anystruct any) (map[string]any, error)

FieldMap returns a map of all field names and values that can be used at runtime without panicking.

func FieldNames

func FieldNames(anystruct any) ([]string, error)

FieldNames returns a string list of all field names that can be used at runtime without panicking.

Types

type JSONPrinter

type JSONPrinter[T any] struct{}

func (*JSONPrinter[T]) Print

func (p *JSONPrinter[T]) Print(s T, w io.Writer) error

func (*JSONPrinter[T]) PrintAll

func (p *JSONPrinter[T]) PrintAll(slice []T, w io.Writer) error

func (*JSONPrinter[T]) PrintNewLine

func (p *JSONPrinter[T]) PrintNewLine(w io.Writer) error

func (*JSONPrinter[T]) Render

func (p *JSONPrinter[T]) Render(s T) ([]byte, error)

func (*JSONPrinter[T]) RenderAll

func (p *JSONPrinter[T]) RenderAll(slice []T) ([]byte, error)

type Printer

type Printer[T any] interface {
	Print(T, io.Writer) error
	PrintAll([]T, io.Writer) error
}

type Renderer

type Renderer[T any] interface {
	Render(T) ([]byte, error)
	RenderAll([]T) ([]byte, error)
}

type RendererPrinter

type RendererPrinter[T any] interface {
	Renderer[T]
	Printer[T]
}

type TablePrinter

type TablePrinter[T any] struct {
	sync.Mutex
	WithHeader bool
	// contains filtered or unexported fields
}

func (*TablePrinter[T]) Print

func (p *TablePrinter[T]) Print(s T, w io.Writer) error

func (*TablePrinter[T]) PrintAll

func (p *TablePrinter[T]) PrintAll(slice []T, w io.Writer) error

func (*TablePrinter[T]) Render

func (p *TablePrinter[T]) Render(s T) ([]byte, error)

func (*TablePrinter[T]) RenderAll

func (p *TablePrinter[T]) RenderAll(slice []T) ([]byte, error)

func (*TablePrinter[T]) Reset

func (p *TablePrinter[T]) Reset()

func (*TablePrinter[T]) SetFieldNames

func (p *TablePrinter[T]) SetFieldNames(fieldNames []string)

SetFieldNames allows you to customize which field names are printed and in what order, instead of automatically deriving and printing all fields in their definition order.

func (*TablePrinter[T]) SetWithHeader

func (p *TablePrinter[T]) SetWithHeader(withHeader bool)

SetWithHeader is a flag that determines whether the table is rendered with a header.

type YAMLPrinter

type YAMLPrinter[T any] struct{}

func (*YAMLPrinter[T]) Print

func (p *YAMLPrinter[T]) Print(s T, w io.Writer) error

func (*YAMLPrinter[T]) PrintAll

func (p *YAMLPrinter[T]) PrintAll(slice []T, w io.Writer) error

func (*YAMLPrinter[T]) Render

func (p *YAMLPrinter[T]) Render(s T) ([]byte, error)

func (*YAMLPrinter[T]) RenderAll

func (p *YAMLPrinter[T]) RenderAll(slice []T) ([]byte, error)

Jump to

Keyboard shortcuts

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