hanap

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2019 License: MIT Imports: 9 Imported by: 1

README

hanap

Un encodeur au format "logfmt"

Documentation

Index

Constants

View Source
const Version = "0.2.0"

Version est le numéro de la version actuelle de ce module.

Variables

View Source
var ErrInvalidKey = errors.New("invalid key")

ErrInvalidKey is returned by Marshal functions and Encoder methods if, after dropping invalid runes, a key is empty.

View Source
var ErrNilKey = errors.New("nil key")

ErrNilKey is returned by Marshal functions and Encoder methods if a key is a nil interface or pointer value.

View Source
var ErrUnsupportedKeyType = errors.New("unsupported key type")

ErrUnsupportedKeyType is returned by Encoder methods if a key has an unsupported type.

View Source
var ErrUnsupportedValueType = errors.New("unsupported value type")

ErrUnsupportedValueType is returned by Encoder methods if a value has an unsupported type.

Functions

func MarshalKeyvals added in v0.2.0

func MarshalKeyvals(keyvals ...interface{}) ([]byte, error)

MarshalKeyvals returns the logfmt encoding of keyvals, a variadic sequence of alternating keys and values.

Types

type Encoder

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

An Encoder writes logfmt data to an output stream.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns a new encoder that writes to w.

func (*Encoder) EncodeKeyval added in v0.2.0

func (enc *Encoder) EncodeKeyval(key, value interface{}) error

EncodeKeyval writes the logfmt encoding of key and value to the stream. A single space is written before the second and subsequent keys in a record. Nothing is written if a non-nil error is returned.

func (*Encoder) EncodeKeyvals added in v0.2.0

func (enc *Encoder) EncodeKeyvals(keyvals ...interface{}) error

EncodeKeyvals writes the logfmt encoding of keyvals to the stream. Keyvals is a variadic sequence of alternating keys and values. Keys of unsupported type are skipped along with their corresponding value. Values of unsupported type or that cause a MarshalerError are replaced by their error but do not cause EncodeKeyvals to return an error. If a non-nil error is returned some key/value pairs may not have be written.

func (*Encoder) EndRecord added in v0.2.0

func (enc *Encoder) EndRecord() error

EndRecord writes a newline character to the stream and resets the encoder to the beginning of a new record.

func (*Encoder) Reset

func (enc *Encoder) Reset()

Reset resets the encoder to the beginning of a new record.

type MarshalerError added in v0.2.0

type MarshalerError struct {
	Type reflect.Type
	Err  error
}

MarshalerError represents an error encountered while marshaling a value.

func (*MarshalerError) Error added in v0.2.0

func (e *MarshalerError) Error() string

Jump to

Keyboard shortcuts

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