config: handle empty configurations

This commit is contained in:
Vincent Bernat
2022-07-08 09:17:10 +02:00
parent 328d11158e
commit 15fc92bfe3
2 changed files with 39 additions and 1 deletions

View File

@@ -188,7 +188,12 @@ func DefaultHook() (mapstructure.DecodeHookFunc, func()) {
// We already have a pointer
method, ok := to.Type().MethodByName("Reset")
if !ok {
return from.Interface(), nil
// We may have a pointer to a pointer when totally empty.
to = to.Elem()
method, ok = to.Type().MethodByName("Reset")
if !ok {
return from.Interface(), nil
}
}
if to.IsNil() {
new := reflect.New(to.Type().Elem())