Tree.Marshal returns the TOML encoding of Tree (#306)
The Tree.Marshal tried to marshal the Tree struct itself rather than the nodes being part of the tree. Fixes #295
This commit is contained in:
committed by
Thomas Pelletier
parent
091e2dc498
commit
75654e60b8
+5
-2
@@ -445,8 +445,11 @@ func (t *Tree) Unmarshal(v interface{}) error {
|
||||
// See Marshal() documentation for types mapping table.
|
||||
func (t *Tree) Marshal() ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
err := NewEncoder(&buf).Encode(t)
|
||||
return buf.Bytes(), err
|
||||
_, err := t.WriteTo(&buf)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
// Unmarshal parses the TOML-encoded data and stores the result in the value
|
||||
|
||||
Reference in New Issue
Block a user