formatter

package
v0.0.0-...-bcb8294 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter interface {
	Format(data interface{}) error
	Name() string
}

Formatter is the interface for all data output formatters.

func New

func New(writer io.Writer, name string) Formatter

New creates the proper formatter based on the given name.

type JSON

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

JSON formats into text.

func NewJSON

func NewJSON(writer io.Writer) *JSON

NewJSON acts as the factory for formatter.JSON.

func (*JSON) Format

func (f *JSON) Format(data interface{}) error

Format formats data as json output.

func (*JSON) Name

func (f *JSON) Name() string

Name obtains the name of the formatter.

type Text

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

Text is the formatter to format data into readable text.

func NewText

func NewText(writer io.Writer) *Text

NewText acts as the factory for formatter.Text.

func (*Text) Format

func (f *Text) Format(data interface{}) error

Format formats data as simple text output.

func (*Text) Name

func (f *Text) Name() string

Name obtains the name of the formatter.

type YAML

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

YAML formats into yaml.

func NewYAML

func NewYAML(writer io.Writer) *YAML

NewYAML acts as the factory for formatter.YAML.

func (*YAML) Format

func (f *YAML) Format(data interface{}) error

Format formats data as yaml output.

func (*YAML) Name

func (f *YAML) Name() string

Name obtains the name of the formatter.

Jump to

Keyboard shortcuts

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