remove case

This commit is contained in:
filifa 2024-07-11 22:43:16 -05:00
parent a17786e98c
commit bf7b45bcc6
1 changed files with 4 additions and 3 deletions

View File

@ -79,11 +79,12 @@ func patch(obj any, path string, value any) error {
if !found {
err = setValue(obj, first, value)
return err
} else if first == "" {
err = patch(obj, rest, value)
return err
}
switch v := obj.(type) {
case *FeedResponse:
err = patch(map[string]any(*v), rest, value)
case map[string]any:
err = patch(v[first], rest, value)
case []any:
@ -105,7 +106,7 @@ func (f *FeedResponse) Patch(instr *instruction) {
// TODO: need to handle each type of instruction separately: add,
// replace, remove, copy, move
log.Println("updating", instr.Path)
err := patch(f, instr.Path, instr.Value)
err := patch(map[string]any(*f), instr.Path, instr.Value)
if err != nil {
log.Println(err)
}