Skip to content

Example of roundtrip with node and processing (modification) #297

Open
@marco-m-pix4d

Description

@marco-m-pix4d

Hello,
thanks for this library!

If I use yaml.MapSlice I am able to easily perform a roundtrip YAML -> Go -> YAML, modify some elements and write them back in the same order, which is very important for any kind of YAML processing to be validated by a human.

Now I would like to go one step further: my input YAML contains anchors and aliases, so I cannot just use yaml.MapSlice to keep the order, since the YAML anchors are expanded by the decoding, so that if I were to write back the YAML, also without any modification, I would still write back all the anchors expanded, which is not what I want.

So I looked at ast.Node, but I am not sure how to use it; by looking at the API, I could not find a way to go back from node to YAML. I might be missing something obvious ?

Probably related: #285

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions