#231·yaml

Encode []byte as base64 string (to be consistent with stdlib JSON)

Author: johanbrandhorstCreated Dec 20, 2016Updated Mar 16, 2025

The standard library JSON module automatically converts any []byte struct members to base64 encoded strings when marshalling (see https://golang.org/pkg/encoding/json/#Marshal). The YAML library does not, and instead outputs a []byte as an array of bytes, like so:

yaml
bytes:
  - 54
  - 32

I think it would be nice for go-yaml to be consistent with the go standard library behaviour for JSON.