diff --git a/config/config.go b/config/config.go index 8e719562..61e33061 100644 --- a/config/config.go +++ b/config/config.go @@ -39,7 +39,7 @@ func Register(name string, adapter Config) { if adapter == nil { panic("config: Register adapter is nil") } - if _, dup := adapters[name]; dup { + if _, ok := adapters[name]; ok { panic("config: Register called twice for adapter " + name) } adapters[name] = adapter diff --git a/config/fake.go b/config/fake.go index dba1a470..561dccca 100644 --- a/config/fake.go +++ b/config/fake.go @@ -20,13 +20,11 @@ type fakeConfigContainer struct { } func (c *fakeConfigContainer) getData(key string) string { - key = strings.ToLower(key) - return c.data[key] + return c.data[strings.ToLower(key)] } func (c *fakeConfigContainer) Set(key, val string) error { - key = strings.ToLower(key) - c.data[key] = val + c.data[strings.ToLower(key)] = val return nil } @@ -55,8 +53,7 @@ func (c *fakeConfigContainer) Float(key string) (float64, error) { } func (c *fakeConfigContainer) DIY(key string) (interface{}, error) { - key = strings.ToLower(key) - if v, ok := c.data[key]; ok { + if v, ok := c.data[strings.ToLower(key)]; ok { return v, nil } return nil, errors.New("key not find")