encoder: inline tables create map in nil interface (#496)

Co-authored-by: Thomas Pelletier <pelletier.thomas@gmail.com>
This commit is contained in:
Cameron Moore
2021-04-09 08:02:00 -05:00
committed by GitHub
parent e1f035461b
commit 466bfe8664
3 changed files with 35 additions and 6 deletions
+8
View File
@@ -159,6 +159,14 @@ func ensureValueIndexable(t target) error {
var sliceInterfaceType = reflect.TypeOf([]interface{}{})
var mapStringInterfaceType = reflect.TypeOf(map[string]interface{}{})
func ensureMapIfInterface(x target) {
v := x.get()
if v.Kind() == reflect.Interface && v.IsNil() {
newElement := reflect.MakeMap(mapStringInterfaceType)
x.set(newElement)
}
}
func setString(t target, v string) error {
f := t.get()