Documentation
¶
Overview ¶
Package yaml provides a streaming YAML github.com/alexfalkowski/go-service/v2/encoding/stream.Encoder/ github.com/alexfalkowski/go-service/v2/encoding/stream.Decoder pair used by go-service.
It wraps go.yaml.in/yaml/v3's own NewEncoder/NewDecoder types, which are each bound to one writer/reader for many Encode/Decode calls. It carries over the strict decoding policy of github.com/alexfalkowski/go-service/v2/encoding/yaml (unknown fields rejected), but drops that package's trailing-document rejection, since a stream is expected to contain many documents. Encoder is a direct alias of the upstream type, so its Close is not idempotent — a second call surfaces upstream's "expected nothing after STREAM-END" error; callers must call Close exactly once, at the true end of the stream, per github.com/alexfalkowski/go-service/v2/encoding/stream.Encoder's contract. See NewEncoder.
Start with the package-level constructors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Decoder ¶
Decoder streams YAML values from a reader bound at construction.
Decoder embeds the go.yaml.in/yaml/v3.Decoder, so [Decoder.Decode] is the embedded decoder's own method. Decoder satisfies github.com/alexfalkowski/go-service/v2/encoding/stream.Decoder structurally, without this package importing that package: the underlying decoder has no Close method at all, so this thin wrapper exists only to add one.
func NewDecoder ¶
NewDecoder constructs a streaming YAML Decoder bound to r.
Unlike github.com/alexfalkowski/go-service/v2/encoding/yaml.Encoder's Decode, the returned decoder allows additional YAML documents after the first: it does not enforce single-value trailing-data rejection, since a stream is expected to carry many documents. Unknown fields remain rejected.
func (*Decoder) Close ¶
Close is a no-op: go.yaml.in/yaml/v3's Decoder has no Close method or finalization state.
type Encoder ¶
Encoder is an alias of go.yaml.in/yaml/v3.Encoder.
Encoder already satisfies github.com/alexfalkowski/go-service/v2/encoding/stream.Encoder structurally (Encode and Close), so no wrapper type is needed.
Note: the underlying Close is not idempotent — a second call returns "yaml: expected nothing after STREAM-END". Callers must call Close exactly once, at the end of the stream.