format

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2018 License: Apache-2.0 Imports: 8 Imported by: 2 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeFormatter

func InitializeFormatter(ftype string, out io.Writer)

InitializeFormatter creates a singleton Formatter

Types

type Formatter

type Formatter interface {
	PrintItem(item interface{}) error
	PrintList(items interface{}) error
	//PrintList(items [][]string, headers []string) 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 an 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