Open mrueg opened 5 days ago
What makes the empty fields go away is the following pipeline: {{ .Object |toJson | fromJson | toYaml }}
as json seems to omit the empty fields by default.
Hello, good catch, toYaml
needs to follow the same logic as toJson
, I will tag this one as bug and works on it soon :)
Thanks for your report
@mrueg Hi thanks for your patience, I have add a test on https://github.com/go-sprout/sprout/pull/96, but the omitempty
and -
seams to be resolve normally, can you have an example to provide ?
Thanks for creating a test cases. Looking again at it, I can't reproduce it in a minimal example (tried a few and it works as expected). I'm using it in a library that does a lot of things with the struct in between (e.g. json marshalling and unmarshalling), so I'll need to take a look deeper and hopefully can reproduce it then.
You have a proposal, explain it!
Right now toYaml represents the whole object. It would be great if there were an option to allow it to ignore empty fields.
Describe the solution you'd like
Have new toYamlWithParams function maybe with https://github.com/go-sprout/sprout/issues/79 that allows setting omitting empty fields as well as setting indentation.
Additional context
No response
Code of Conduct