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
|
||||
}
|
||||
|
||||
if idx < len(v) {
|
||||
v[idx] = value
|
||||
} else {
|
||||
v = append(v, value)
|
||||
if len(v) <= idx {
|
||||
arr := make([]any, idx+1)
|
||||
for i, val := range v {
|
||||
arr[i] = val
|
||||
}
|
||||
v = arr
|
||||
}
|
||||
v[idx] = value
|
||||
default:
|
||||
err = errors.New("couldn't determine type")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue