summaryrefslogtreecommitdiff
path: root/vendor/github.com/spf13/viper/internal/encoding/dotenv/map_utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/spf13/viper/internal/encoding/dotenv/map_utils.go')
-rw-r--r--vendor/github.com/spf13/viper/internal/encoding/dotenv/map_utils.go41
1 files changed, 0 insertions, 41 deletions
diff --git a/vendor/github.com/spf13/viper/internal/encoding/dotenv/map_utils.go b/vendor/github.com/spf13/viper/internal/encoding/dotenv/map_utils.go
deleted file mode 100644
index 8bfe0a9de..000000000
--- a/vendor/github.com/spf13/viper/internal/encoding/dotenv/map_utils.go
+++ /dev/null
@@ -1,41 +0,0 @@
-package dotenv
-
-import (
- "strings"
-
- "github.com/spf13/cast"
-)
-
-// flattenAndMergeMap recursively flattens the given map into a new map
-// Code is based on the function with the same name in the main package.
-// TODO: move it to a common place.
-func flattenAndMergeMap(shadow, m map[string]any, prefix, delimiter string) map[string]any {
- if shadow != nil && prefix != "" && shadow[prefix] != nil {
- // prefix is shadowed => nothing more to flatten
- return shadow
- }
- if shadow == nil {
- shadow = make(map[string]any)
- }
-
- var m2 map[string]any
- if prefix != "" {
- prefix += delimiter
- }
- for k, val := range m {
- fullKey := prefix + k
- switch val := val.(type) {
- case map[string]any:
- m2 = val
- case map[any]any:
- m2 = cast.ToStringMap(val)
- default:
- // immediate value
- shadow[strings.ToLower(fullKey)] = val
- continue
- }
- // recursively merge to shadow map
- shadow = flattenAndMergeMap(shadow, m2, fullKey, delimiter)
- }
- return shadow
-}