miller/pkg/output
chaoliang yan 5e8175bc6b
fix: preserve key order in YAML output (#2034)
* fix: preserve key order in YAML output

MlrmapToYAMLNative converted the ordered Mlrmap to map[string]interface{},
which loses insertion order. yaml.v3.Marshal then sorts Go map keys
alphabetically, so YAML output always had sorted keys despite other formats
(JSON, pretty-print) correctly preserving order.

Switch to building yaml.Node trees that preserve the Mlrmap's linked-list
iteration order. Use yaml.Node.Encode for scalar values to correctly handle
edge cases (NaN/Inf, non-UTF-8 strings).

Fixes #2028.

* Update pkg/mlrval/mlrval_yaml_test.go with copilot code-review feedback

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: lawrence3699 <lawrence3699@users.noreply.github.com>
Co-authored-by: John Kerl <kerl.john.r@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-12 09:43:09 -04:00
..
channel_writer.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
doc.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
file_output_handlers.go Some fixes for staticcheck (#2006) 2026-03-03 09:27:03 -05:00
README.md Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
record_writer.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
record_writer_csv.go Resolve a few to-do comments in the source code (#1951) 2026-02-01 18:14:20 -05:00
record_writer_csv_colorizer.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
record_writer_csvlite.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
record_writer_dcf.go Some fixes for staticcheck (#2006) 2026-03-03 09:27:03 -05:00
record_writer_dkvp.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
record_writer_dkvpx.go Add DKVPX file format (#2002) 2026-03-02 22:35:08 -05:00
record_writer_factory.go Add DKVPX file format (#2002) 2026-03-02 22:35:08 -05:00
record_writer_json_jsonl.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
record_writer_markdown.go Neaten some comments (#1973) 2026-02-16 13:38:49 -05:00
record_writer_nidx.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
record_writer_pprint.go Add unicode printing support for barred output (#1984) 2026-02-21 23:15:03 -05:00
record_writer_tsv.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
record_writer_xtab.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
record_writer_yaml.go fix: preserve key order in YAML output (#2034) 2026-04-12 09:43:09 -04:00

Logic for formatting output records as strings to standard output.

There is one record-writer type per supported output file format, and a factory method.