Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small float values can't be decoded after an unmarshal-marshal round trip #458

Closed
cooscoos opened this issue Jul 1, 2024 · 0 comments · Fixed by #463
Closed

Small float values can't be decoded after an unmarshal-marshal round trip #458

cooscoos opened this issue Jul 1, 2024 · 0 comments · Fixed by #463
Labels
bug Something isn't working

Comments

@cooscoos
Copy link

cooscoos commented Jul 1, 2024

Describe the bug
Take a small float value in yaml, e.g.:

value: 0.00001

then:

  1. unmarshal it from yaml to a map[string]interface{}
  2. marshal that map back into a new yaml.

That new yaml now cannot be decoded because the unmarshal + marshal step changes value from 0.00001 to 1e-05.

1e-05 is interpreted by the final decoder as a string.

To Reproduce

Playground example:
https://go.dev/play/p/mxsL_Dp_naC

This issue affects values of 0.00001 (1e-05) or lower. Larger values (e.g. 0.0001, 10000000000) are fine.

Expected behavior
Unmarshal-marshal should result in yaml that a decoder can parse.

Version Variables

  • Go version: v1.22
  • go-yaml's Version: v1.11.3
@cooscoos cooscoos added the bug Something isn't working label Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant