You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd say that both go-yaml/yamlandgoccy/yaml are incorrect.
Outputing a 1 for a float value of 1.0 is incorrect, by my reading of the YAML spec; it means that float values don't round-trip correctly, because when you read it back in, it will be an int instead. Note that this isn't aesthetic; YAML is a typed file format, and an untagged 1 is an int, not a float.
goccy/yamlcorrectly outputs 1.0 for a float value of 1.0, but, unfortunately, it weirdly fails to support float values with more than seven digits after the decimal point: https://play.golang.org/p/n9z9jZ2dPBI, a case that go-yaml actually handles correctly.
I'd say that ideally the correct method would be to use strconv.FormatFloat the way go-yaml does, but then check if the resulting string contains a . (or scientific notation) and, if not, append .0.
Marshal result of a float value without decimal part is not same with go-yaml/yaml.
This behavior is not also same with JSON marshalers and not comfortable when roundtrip.
The text was updated successfully, but these errors were encountered: