-
Notifications
You must be signed in to change notification settings - Fork 212
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
tree.Marshal() returns empty bytes without any errors #295
Comments
Thanks for the bug report! That definitely looks wrong. |
I don't understand why the func (t *Tree) Marshal() ([]byte, error) {
var buf bytes.Buffer
err := NewEncoder(&buf).Encode(t)
return buf.Bytes(), err
} What do you think about replacing the encoding part with func (t *Tree) Marshal() ([]byte, error) {
var buf bytes.Buffer
_, err := t.WriteTo(&buf)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
} |
That makes sense. Looks like This is the kind of function that I regret having published. There are 4 ways to emit a TOML document:
The last two are here to mirror the standard |
The Tree.Marshal tried to marshal the Tree struct itself rather than the nodes being part of the tree. Fixes pelletier#295
The Tree.Marshal tried to marshal the Tree struct itself rather than the nodes being part of the tree. Fixes pelletier#295
Describe the bug
tree.Marshal()
returns empty bytes without any errors.To Reproduce
Expected behavior
It returns TOML content.
Versions
The text was updated successfully, but these errors were encountered: