Examples
Each example page illustrates one task and works it through.
The code comes from Example functions in docs/examples.
This is a module of its own, with actual tests run in CI that check every output printed here.
To run a recipe:
Examples for Decoding into Go values and Working with documents each describe how to use options and type in full. The dedicated examples below show them at work.
- Reading YAML into Go values: struct tags, strictness, validation, streams, anchors and key order.
- Writing Go values as YAML: the output style, and comments kept through a round trip.
- Working on the document itself: editing it in place, finding a key’s position, reading part of a large file, rewriting and coloring it.
- YAML to JSON and back, without building a Go value.