Don't wrap native types in a tomlValue{}

This commit is contained in:
Evan Phoenix
2014-11-05 09:23:41 -08:00
parent 34da10d880
commit 71e7762db5
+15 -1
View File
@@ -191,7 +191,21 @@ func (t *TomlTree) SetPath(keys []string, value interface{}) {
subtree = node[len(node)-1] subtree = node[len(node)-1]
} }
} }
subtree.values[keys[len(keys)-1]] = &tomlValue{value: value}
var toInsert interface{}
switch value.(type) {
case *TomlTree:
toInsert = value
case []*TomlTree:
toInsert = value
case *tomlValue:
toInsert = value
default:
toInsert = &tomlValue{value: value}
}
subtree.values[keys[len(keys)-1]] = toInsert
} }
// createSubTree takes a tree and a key and create the necessary intermediate // createSubTree takes a tree and a key and create the necessary intermediate