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

Unmarshal of empty input should return empty map #602

Closed
moorereason opened this issue Sep 22, 2021 · 2 comments
Closed

Unmarshal of empty input should return empty map #602

moorereason opened this issue Sep 22, 2021 · 2 comments
Labels
bug Issues describing a bug in go-toml. v2 Issues impacting the v2 major version.
Milestone

Comments

@moorereason
Copy link
Contributor

moorereason commented Sep 22, 2021

Describe the bug
An empty input currently results in a <nil> result when unmarshaled into interface{}.

To Reproduce
https://play.golang.org/p/qYCSR7Hrjc3

var v interface{}
toml.Unmarshal([]byte(""), &v)

Expected behavior
According to this toml-lang/toml issue, it should result in an empty map (BurntSushi returns an empty map[string]interface{}).

Versions

  • go-toml: v2 ee9b902
  • go version devel go1.18-113da92ab63 Mon Sep 20 18:11:57 2021 -0400 linux/amd64
@pelletier pelletier added the bug Issues describing a bug in go-toml. label Sep 25, 2021
@pelletier
Copy link
Owner

Nice edge case, probably comes from the strategy of trying to allocate as little as necessary. Thanks!

@pelletier pelletier modified the milestones: v2.0.0-beta.4, v2.0.0-beta.5 Oct 3, 2021
@pelletier pelletier added the v2 Issues impacting the v2 major version. label Oct 3, 2021
@pelletier pelletier changed the title v2: unmarshal of empty input should return empty map unmarshal of empty input should return empty map Oct 3, 2021
@pelletier pelletier changed the title unmarshal of empty input should return empty map Unmarshal of empty input should return empty map Oct 3, 2021
@pelletier pelletier added this to the v2.0.0-beta.4 milestone Oct 23, 2021
pelletier added a commit that referenced this issue Oct 25, 2021
pelletier added a commit that referenced this issue Oct 25, 2021
@pelletier
Copy link
Owner

Fixed inhttps://github.com/pelletier/go-toml/commit/64941b99e2bfbaf6f1c1fcfefd51d055beaafcbf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues describing a bug in go-toml. v2 Issues impacting the v2 major version.
Projects
None yet
Development

No branches or pull requests

2 participants