serialize

package
v2.120.1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorToString

func ErrorToString(err error) (ret string)

ErrorToString converts an error to a string, handling panics if they occur.

func KVFormat added in v2.90.0

func KVFormat(b *bytes.Buffer, k, v interface{})

func KVListFormat

func KVListFormat(b *bytes.Buffer, keysAndValues ...interface{})

func MarshalerToValue added in v2.70.0

func MarshalerToValue(m logr.Marshaler) (ret interface{})

MarshalerToValue invokes a marshaler and catches panics.

func MergeAndFormatKVs added in v2.90.0

func MergeAndFormatKVs(b *bytes.Buffer, first, second []interface{})

func MergeKVs added in v2.70.0

func MergeKVs(first, second []interface{}) []interface{}

MergeKVs deduplicates elements provided in two key/value slices.

Keys in each slice are expected to be unique, so duplicates can only occur when the first and second slice contain the same key. When that happens, the key/value pair from the second slice is used. The first slice must be well-formed (= even key/value pairs). The second one may have a missing value, in which case the special "missing value" is added to the result.

func StringerToString

func StringerToString(s fmt.Stringer) (ret string)

StringerToString converts a Stringer to a string, handling panics if they occur.

func WithValues

func WithValues(oldKV, newKV []interface{}) []interface{}

WithValues implements LogSink.WithValues. The old key/value pairs are assumed to be well-formed, the new ones are checked and padded if necessary. It returns a new slice.

Types

type AnyToStringFunc added in v2.90.1

type AnyToStringFunc func(v interface{}) string

type Formatter added in v2.90.1

type Formatter struct {
	AnyToStringHook AnyToStringFunc
}

func (Formatter) KVFormat added in v2.90.1

func (f Formatter) KVFormat(b *bytes.Buffer, k, v interface{})

KVFormat serializes one key/value pair into the provided buffer. A space gets inserted before the pair.

func (Formatter) KVListFormat added in v2.90.1

func (f Formatter) KVListFormat(b *bytes.Buffer, keysAndValues ...interface{})

KVListFormat serializes all key/value pairs into the provided buffer. A space gets inserted before the first pair and between each pair.

func (Formatter) MergeAndFormatKVs added in v2.90.1

func (f Formatter) MergeAndFormatKVs(b *bytes.Buffer, first, second []interface{})

MergeKVsInto is a variant of MergeKVs which directly formats the key/value pairs into a buffer.

Jump to

Keyboard shortcuts

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