Skip to content

Commit

Permalink
Call post-load hook on nested structs
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcook committed Jan 26, 2023
1 parent a96c134 commit 3bc8259
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ func bindStruct(prefix, id string, data map[string]string, typ reflect.Type, val
}

structField.Set(res)

// Call post-load hook
postLoad := res.MethodByName("PostLoad")

if postLoad.IsValid() {
postLoad.Call([]reflect.Value{})
}
} else {
return errors.New("Can't set unsupported struct with key " + inputFieldName)
}
Expand Down

0 comments on commit 3bc8259

Please sign in to comment.