do similar array copy at end of recursion
This commit is contained in:
parent
542c2850a7
commit
8603978c7d
|
@ -54,11 +54,14 @@ func patch(obj any, path string, value any) error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if idx < len(v) {
|
if len(v) <= idx {
|
||||||
v[idx] = value
|
arr := make([]any, idx+1)
|
||||||
} else {
|
for i, val := range v {
|
||||||
v = append(v, value)
|
arr[i] = val
|
||||||
|
}
|
||||||
|
v = arr
|
||||||
}
|
}
|
||||||
|
v[idx] = value
|
||||||
default:
|
default:
|
||||||
err = errors.New("couldn't determine type")
|
err = errors.New("couldn't determine type")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue