From 3c23ee5473e28c4262526a6c3eb4ac74fd5006d8 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Sun, 27 Mar 2022 14:32:28 +0200 Subject: [PATCH] change map offset --- envconf.go | 4 ++-- tests/main.go | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/envconf.go b/envconf.go index 5521d0c..07629c3 100644 --- a/envconf.go +++ b/envconf.go @@ -62,7 +62,7 @@ func NewConfig() *Config { config.mapMapMapEnv[left] = make(map[string]map[string]map[string]string) } config.mapEnv[left][right] = key - if count < len(splitted)-2 { + if count < len(splitted)-1 { middle := splitted[count] right = strings.Join(splitted[count+1:], "_") if len(config.mapMapEnv[left][middle]) == 0 { @@ -70,7 +70,7 @@ func NewConfig() *Config { config.mapMapMapEnv[left][middle] = make(map[string]map[string]string) } config.mapMapEnv[left][middle][right] = key - if count < len(splitted)-3 { + if count < len(splitted)-2 { lmiddle := splitted[count] rmiddle := splitted[count+1] right = strings.Join(splitted[count+2:], "_") diff --git a/tests/main.go b/tests/main.go index f45d84c..a48b310 100644 --- a/tests/main.go +++ b/tests/main.go @@ -11,7 +11,6 @@ func main() { conf.DefineMap("test_map", envconf.TypeInt) conf.Parse() conf.Status() - fmt.Println(conf) - fmt.Println(conf.GetMapInt("test_map")) + fmt.Println(conf.GetMapMapInt("test_map")) fmt.Println(conf.GetInt("this_is_a_map")) }