Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
2efc1a155e
|
|||
45f8b0f918
|
|||
2cdcbec364
|
@ -55,6 +55,7 @@ func NewConfig() *Config {
|
|||||||
if len(config.mapEnv[left]) == 0 {
|
if len(config.mapEnv[left]) == 0 {
|
||||||
config.mapEnv[left] = make(map[string]string)
|
config.mapEnv[left] = make(map[string]string)
|
||||||
}
|
}
|
||||||
|
fmt.Printf("left=(%s), right=(%s), key=(%s)\n", left, right, key)
|
||||||
config.mapEnv[left][right] = key
|
config.mapEnv[left][right] = key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,9 +86,11 @@ func (c *Config) Define(key string, dtype DataType) {
|
|||||||
// Variables without a defined type will be ignored by Parse.
|
// Variables without a defined type will be ignored by Parse.
|
||||||
func (c *Config) DefineMap(key string, dtype DataType) {
|
func (c *Config) DefineMap(key string, dtype DataType) {
|
||||||
key = cleanKey(key)
|
key = cleanKey(key)
|
||||||
|
fmt.Println(c.mapEnv)
|
||||||
entries, ok := c.mapEnv[key]
|
entries, ok := c.mapEnv[key]
|
||||||
if ok {
|
if ok {
|
||||||
for _, key = range entries {
|
for _, key = range entries {
|
||||||
|
fmt.Printf("key-from-define-map (%s)\n", key)
|
||||||
entry := c.env[key]
|
entry := c.env[key]
|
||||||
entry.dtype = dtype
|
entry.dtype = dtype
|
||||||
c.env[key] = entry
|
c.env[key] = entry
|
||||||
|
@ -7,9 +7,11 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
conf := envconf.NewConfig()
|
conf := envconf.NewConfig()
|
||||||
conf.Define("this_is_a_map", envconf.FixedHex(22))
|
conf.Define("this_is_a_map", envconf.TypeInt)
|
||||||
|
conf.Define("test_map", envconf.TypeInt)
|
||||||
conf.Parse()
|
conf.Parse()
|
||||||
conf.Status()
|
conf.Status()
|
||||||
|
|
||||||
fmt.Println(conf.GetHex("this_is_a_map"))
|
fmt.Println(conf.GetMapInt("test_map"))
|
||||||
|
fmt.Println(conf.GetInt("this_is_a_map"))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user