format

package
v0.11.0-beta Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeFormatter

func InitializeFormatter(formatterType string, out io.Writer)

InitializeFormatter creates a singleton Formatter

Types

type Formatter

type Formatter interface {
	PrintItem(item interface{}) error
	PrintList(items interface{}) error
	PrintError(context string, err error)
	PrintFatal(context string, err error)
}

Formatter defines output printing interface

func GetFormatter

func GetFormatter() Formatter

GetFormatter creates a new JSONFormatter

type JSONFormatter

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

JSONFormatter prints items and lists in JSON format

func NewJSONFormatter

func NewJSONFormatter(out io.Writer) *JSONFormatter

NewJSONFormatter creates a new JSONFormatter

func (*JSONFormatter) PrintError

func (f *JSONFormatter) PrintError(context string, err error)

PrintError prints an error

func (*JSONFormatter) PrintFatal

func (f *JSONFormatter) PrintFatal(context string, err error)

PrintFatal prints an error and exists

func (*JSONFormatter) PrintItem

func (f *JSONFormatter) PrintItem(item interface{}) error

PrintItem prints an item

func (*JSONFormatter) PrintList

func (f *JSONFormatter) PrintList(items interface{}) error

PrintList prints item list

type JSONMessage

type JSONMessage struct {
	Type    string `json:"type"`
	Context string `json:"context,omitempty"`
	Message string `json:"message"`
}

JSONMessage hosts generic messages

type TextFormatter

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

TextFormatter prints items and lists

func NewTextFormatter

func NewTextFormatter(out io.Writer) *TextFormatter

NewTextFormatter creates a new TextFormatter

func (*TextFormatter) PrintError

func (f *TextFormatter) PrintError(context string, err error)

PrintError prints an error

func (*TextFormatter) PrintFatal

func (f *TextFormatter) PrintFatal(context string, err error)

PrintFatal prints an error and exists

func (*TextFormatter) PrintItem

func (f *TextFormatter) PrintItem(item interface{}) error

PrintItem prints item

func (*TextFormatter) PrintList

func (f *TextFormatter) PrintList(items interface{}) error

PrintList prints item list

Jump to

Keyboard shortcuts

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