Open nyarly opened 3 years ago
@nyarly did you perhaps mean to reference https://pkg.go.dev/cuelang.org/go@v0.4.0/encoding/yaml above? cuelang.org/go/pkg/encoding/yaml
is definition of the builtin package encoding/yaml
.
I'd found the pkg
implementation and was using that. The nice thing about using Encode
is that it would be a []byte
value already, so we can save a conversion.
Being able to stream the output remains a (perhaps only aesthetic) benefit.
Indeed. The pattern from encoding/json
of being able to create encoders/decoders that effectively wrap an io.{Reader,Writer}
makes sense. Any such implementation would however live in the encoding/yaml
package, not the builtin pkg/encoding/yaml
.
Building a Go tool emit multiple files, I need to be able to emit JSON and YAML based on CUE values.
For JSON, I have
(just using Go's encoding/json)
For YAML it's like
It'd be great to have a streaming YAML encoder. I think encoding a string, converting to bytes, and then writing is probably not my biggest performance problem, but it couldn't hurt.