From 3bc8259f09251f6562339bf691e652822b653fdb Mon Sep 17 00:00:00 2001 From: Jack Cook Date: Thu, 26 Jan 2023 10:46:41 -0800 Subject: [PATCH] Call post-load hook on nested structs --- bind.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bind.go b/bind.go index 03a9950..45c398c 100644 --- a/bind.go +++ b/bind.go @@ -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) }