summaryrefslogtreecommitdiffstats
path: root/common/maps/maps.go
diff options
context:
space:
mode:
Diffstat (limited to 'common/maps/maps.go')
-rw-r--r--common/maps/maps.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/common/maps/maps.go b/common/maps/maps.go
index 5552da55d..2d8a122ca 100644
--- a/common/maps/maps.go
+++ b/common/maps/maps.go
@@ -109,6 +109,20 @@ func ToSliceStringMap(in any) ([]map[string]any, error) {
}
}
+// LookupEqualFold finds key in m with case insensitive equality checks.
+func LookupEqualFold[T any | string](m map[string]T, key string) (T, bool) {
+ if v, found := m[key]; found {
+ return v, true
+ }
+ for k, v := range m {
+ if strings.EqualFold(k, key) {
+ return v, true
+ }
+ }
+ var s T
+ return s, false
+}
+
type keyRename struct {
pattern glob.Glob
newKey string