+7
-1
@@ -174,7 +174,13 @@ func (d *decoder) FromParser(v interface{}) error {
|
|||||||
return fmt.Errorf("toml: decoding pointer target cannot be nil")
|
return fmt.Errorf("toml: decoding pointer target cannot be nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := d.fromParser(r.Elem())
|
r = r.Elem()
|
||||||
|
if r.Kind() == reflect.Interface && r.IsNil() {
|
||||||
|
newMap := map[string]interface{}{}
|
||||||
|
r.Set(reflect.ValueOf(newMap))
|
||||||
|
}
|
||||||
|
|
||||||
|
err := d.fromParser(r)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return d.strict.Error(d.p.data)
|
return d.strict.Error(d.p.data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1800,6 +1800,16 @@ func TestIssue596(t *testing.T) {
|
|||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIssue602(t *testing.T) {
|
||||||
|
var v interface{}
|
||||||
|
err := toml.Unmarshal([]byte(""), &v)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
var expected interface{} = map[string]interface{}{}
|
||||||
|
|
||||||
|
require.Equal(t, expected, v)
|
||||||
|
}
|
||||||
|
|
||||||
//nolint:funlen
|
//nolint:funlen
|
||||||
func TestUnmarshalDecodeErrors(t *testing.T) {
|
func TestUnmarshalDecodeErrors(t *testing.T) {
|
||||||
examples := []struct {
|
examples := []struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user