Fix backward incompatibility for Set* methods (#213)

Patch #185 introduced a backward incompatibility by changing the arguments
of the `Set*` methods on `Tree`.

This change restores the arguments to what they previous were, and
introduces `SetWithComment` and `SetPathWithComment` to perform the same
action.
This commit is contained in:
Thomas Pelletier
2018-01-18 14:54:55 -08:00
committed by GitHub
parent 778c285afa
commit acdc450948
4 changed files with 21 additions and 9 deletions
+3 -3
View File
@@ -230,7 +230,7 @@ func (e *Encoder) valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, er
if err != nil {
return nil, err
}
tval.Set(opts.name, opts.comment, opts.commented, val)
tval.SetWithComment(opts.name, opts.comment, opts.commented, val)
}
}
case reflect.Map:
@@ -245,9 +245,9 @@ func (e *Encoder) valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, er
if err != nil {
return nil, err
}
tval.SetPath([]string{keyStr}, "", false, val)
tval.SetPath([]string{keyStr}, val)
} else {
tval.Set(key.String(), "", false, val)
tval.Set(key.String(), val)
}
}
}