I have a YAML like
data:
label1:
- someval1
- someval2
label2:
- otherval1
- otehrval2
Using YAML parser "gopkg.in/yaml.v2"
yaml.Unmarshal([]byte(yamlStr), &yamlObj)
# Some works and changes to yamlObj
s, _ := yaml.Marshal(&yamlObj)
fmt.Println(string(s))
This outputs:
data:
label1:
- someval1
- someval2
label2:
- otherval1
- otehrval2
The resulted YAML is correct but for my task I need lists (- values
) indented as in original YAML. Is there a way to preserve those spaces and new lines?