From 6b7724eb51553286ccccb26b7d68f59641b8a91e Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 28 Feb 2024 09:48:20 -0500 Subject: [PATCH] fix: skip unexported fields --- config/config.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/config.go b/config/config.go index ecdcd98..6ed5eea 100644 --- a/config/config.go +++ b/config/config.go @@ -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