types

package module
v0.0.0-...-ccdf5f0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Display

type Display interface {
	// Human readable output.
	Display() string
}

type DisplayWriter

type DisplayWriter interface {
	// Collect accumulated Human Readable output to w.
	// Ignore must not be returned, nor does it should panic, because this is just intended for human read.
	//
	// Interface implementer will not return how much bytes written or error.
	//
	// So ensure the Writer is reliable and can consume everything without error, e.g. bytes.Buffer or strings.Builder.
	WriteDisplay(w StringWriter)
}

type Fielder

type Fielder interface {
	Fields() Fields
}

Interface to convert any type into types.Fields.

type Fields

type Fields map[string]any

func NewFields

func NewFields(values ...any) Fields

Values must be alternating between string and other values, with even index as string. If value is not of type string, it will be coerced to string using fmt.Sprintf.

If len of Values is odd, an extra value of nil will be appended to the end.

If values are empty, an empty map will be returned.

Example:

fields := types.NewFields(
	"foo", "bar",
	"baz", 1,
	"qux", 2,
)

func (Fields) Display

func (f Fields) Display() string

Human readable output.

func (Fields) IsNil

func (f Fields) IsNil() bool

func (Fields) MarshalJSON

func (f Fields) MarshalJSON() ([]byte, error)

func (Fields) MarshalJSONObject

func (f Fields) MarshalJSONObject(enc *gojay.Encoder)

func (Fields) WriteDisplay

func (f Fields) WriteDisplay(s StringWriter)

type Logs

type Logs interface {
	Logs() Fields
}

An interface similar to Fielder, but this one is intended to also hold more confidential values

The user of this interface must be aware of data breaches. So ensure the data never goes out to wrong party.

type StringWriter

type StringWriter interface {
	io.Writer
	io.StringWriter
}

A Writer interface that supports both Write and WriteString.

Jump to

Keyboard shortcuts

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