Documentation
¶
Overview ¶
Package yaml provides YAML encoding helpers and adapters used by go-service.
This package integrates YAML encoding/decoding behind the go-service encoding abstraction.
Start with the package-level constructors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Encoder ¶
type Encoder struct{}
Encoder implements YAML encoding and decoding.
It uses go-yaml v3 with unknown fields and trailing documents rejected.
func NewEncoder ¶
func NewEncoder() *Encoder
NewEncoder constructs a YAML encoder.
This encoder is a thin adapter around go-yaml v3 (imported as go.yaml.in/yaml/v3) that satisfies github.com/alexfalkowski/go-service/v2/encoding/codec.Encoder.
func (*Encoder) Decode ¶
Decode reads YAML from r and decodes it into v.
In most cases v should be a pointer to the destination value (for example *MyStruct). Decode reads one YAML document and rejects unknown fields unless github.com/alexfalkowski/go-service/v2/encoding/codec.WithDiscardUnknown is supplied. It always rejects additional documents in the same stream.
func (*Encoder) Encode ¶
Encode writes v to w as YAML.
Encode closes the upstream YAML encoder after writing so final buffered data and finalization errors are handled. YAML has no required-field concept, so github.com/alexfalkowski/go-service/v2/encoding/codec.WithAllowPartial has no effect.