The yaml.Marshal
appears to split long string values on to multiple lines. Is there any way to prevent this from happening?
The added linebreaks were also unexpected for me (and causes the output not to work, in my case).
Also found an earlier report about this behavior being unexpected (https://github.com/go-yaml/yaml/issues/348).
The 80-character limit is set on the Encoder's emitter: https://github.com/go-yaml/yaml/blob/7c97801ccf41d5273de9e22c8b2af6860c7703a2/emitterc.go#L286
I didn't see a way through the API to modify these settings, but I would definitely be excited to use one.
This feature confuses me too. I use this package to modify ConfigMap of k8s, but after an 'Unmarshal' and a 'Marshal' operations, the configmap appears more differences than I except. Hope for some APIs to define these settings.
The same issue with you guys. I Marshal
the data into a yaml text file, then the function generates an unexpected line break in the marshaled bytes array like below:
Input:
ssh_authorized_keys:- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2Sx8dhcxM16zUIJGUsoHvium2ezzXL5F5obBvWd441BSau1XTDVdO3zOchF3mWvYX5q4JT1CF4GntvM1vc16acuVmkzsjsDe3+4uVPPzJps01vDxVeV1vRM53P2deCUnrFJ48CvrPisyXSOCtUCRFC1pPdvVAnOyTkzboQkCEbt6551bXF2nTnZu7XOSdzAKj+YLIRNf/ecr4hJi9xW7Q4N6gP0C+zn/KjvFQ0QSN5t8Cpbg4ri7uR2Vd4a0ccyJ5TQLRJ3EtAvuVZK3CeY0B3/XlD31cLMSFgLpWDBU2p9OC27Lc3grcYL2kN1A1HsV5AjBWRfTnFuCcOQ7MNdjJ root@ip-xxx-xx-xx-xx
Output:
ssh_authorized_keys:- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC2Sx8dhcxM16zUIJGUsoHvium2ezzXL5F5obBvWd441BSau1XTDVdO3zOchF3mWvYX5q4JT1CF4GntvM1vc16acuVmkzsjsDe3+4uVPPzJps01vDxVeV1vRM53P2deCUnrFJ48CvrPisyXSOCtUCRFC1pPdvVAnOyTkzboQkCEbt6551bXF2nTnZu7XOSdzAKj+YLIRNf/ecr4hJi9xW7Q4N6gP0C+zn/KjvFQ0QSN5t8Cpbg4ri7uR2Vd4a0ccyJ5TQLRJ3EtAvuVZK3CeY0B3/XlD31cLMSFgLpWDBU2p9OC27Lc3grcYL2kN1A1HsV5AjBWRfTnFuCcOQ7MNdjJ
root@ip-xxx-xx-xx-xx
Is there any standard length about the best_width
for golang's yaml?
Since this is getting mentioned, v2.3.0 fixes this by setting the default line length limit to -1 or infinity - see https://github.com/go-yaml/yaml/pull/571
Most helpful comment
The added linebreaks were also unexpected for me (and causes the output not to work, in my case).
Also found an earlier report about this behavior being unexpected (https://github.com/go-yaml/yaml/issues/348).
The 80-character limit is set on the Encoder's emitter: https://github.com/go-yaml/yaml/blob/7c97801ccf41d5273de9e22c8b2af6860c7703a2/emitterc.go#L286
I didn't see a way through the API to modify these settings, but I would definitely be excited to use one.