I tried three different online YAML linters/formatters with that input and 
they gave the same result as you, as does python:

# python3
Python 3.10.12 (main, Feb  4 2025, 14:57:36) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import yaml
>>> data="""
... stuff:
...    keys:
...      - key1
...        - key2
...        - key3
... """
>>> yaml.load(data)
<stdin>:1: YAMLLoadWarning: calling yaml.load() without Loader=... is 
deprecated, as the default Loader is unsafe. Please read 
https://msg.pyyaml.org/load for full details.
{'stuff': {'keys': ['key1 - key2 - key3']}}
>>>

> Is the lesson here that YAML is intended to be easily readable, but not 
easily writable?

I think that's fair, yes.  The YAML specifications (there are several 
versions) are an utter mess, and the way the ambiguities are resolved can 
lead to surprising results. Seeing {{ text interpolation }} in YAML just 
makes me cringe.

If you're looking to generate configurations then there are clearer 
languages like jsonnet and starlark, although they add a lot more 
expressive power and composability that you might not need.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/837af5a4-13aa-408c-9d6c-59be934f0282n%40googlegroups.com.

Reply via email to