fix: skip unexported fields

This commit is contained in:
Derrick Hammer 2024-02-28 09:48:20 -05:00
parent 0ae69e5ba1
commit 6b7724eb51
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 6 additions and 0 deletions

View File

@ -117,6 +117,12 @@ func (m *Manager) setDefaultsForObject(obj interface{}, prefix string) {
for i := 0; i < objValue.NumField(); i++ {
field := objValue.Field(i)
fieldType := objType.Field(i)
// Check if the field is exported and can be interfaced
if !field.CanInterface() {
continue
}
mapstructureTag := fieldType.Tag.Get("mapstructure")
// Construct new prefix based on the mapstructure tag, if available