diff --git a/marshal.go b/marshal.go index 500e00a..3687fa2 100644 --- a/marshal.go +++ b/marshal.go @@ -530,20 +530,20 @@ func (d *Decoder) valueFromToml(mtype reflect.Type, tval interface{}) (reflect.V return d.unwrapPointer(mtype, tval) } - switch tval.(type) { + switch t := tval.(type) { case *Tree: if isTree(mtype) { - return d.valueFromTree(mtype, tval.(*Tree)) + return d.valueFromTree(mtype, t) } return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to a tree", tval, tval) case []*Tree: if isTreeSlice(mtype) { - return d.valueFromTreeSlice(mtype, tval.([]*Tree)) + return d.valueFromTreeSlice(mtype, t) } return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to trees", tval, tval) case []interface{}: if isOtherSlice(mtype) { - return d.valueFromOtherSlice(mtype, tval.([]interface{})) + return d.valueFromOtherSlice(mtype, t) } return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to a slice", tval, tval) default: diff --git a/toml.go b/toml.go index 98c185a..2724af4 100644 --- a/toml.go +++ b/toml.go @@ -215,17 +215,15 @@ func (t *Tree) SetPathWithOptions(keys []string, opts SetOptions, value interfac var toInsert interface{} - switch value.(type) { + switch v := value.(type) { case *Tree: - tt := value.(*Tree) - tt.comment = opts.Comment + v.comment = opts.Comment toInsert = value case []*Tree: toInsert = value case *tomlValue: - tt := value.(*tomlValue) - tt.comment = opts.Comment - toInsert = tt + v.comment = opts.Comment + toInsert = v default: toInsert = &tomlValue{value: value, comment: opts.Comment, commented: opts.Commented, multiline: opts.Multiline} } @@ -278,17 +276,15 @@ func (t *Tree) SetPathWithComment(keys []string, comment string, commented bool, var toInsert interface{} - switch value.(type) { + switch v := value.(type) { case *Tree: - tt := value.(*Tree) - tt.comment = comment + v.comment = comment toInsert = value case []*Tree: toInsert = value case *tomlValue: - tt := value.(*tomlValue) - tt.comment = comment - toInsert = tt + v.comment = comment + toInsert = v default: toInsert = &tomlValue{value: value, comment: comment, commented: commented} }