1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-26 01:01:30 +00:00

code style simplify

This commit is contained in:
fuxiaohei 2014-07-12 16:03:14 +08:00
parent 77c40e6f7b
commit 20e05a3908
2 changed files with 4 additions and 7 deletions

View File

@ -39,7 +39,7 @@ func Register(name string, adapter Config) {
if adapter == nil { if adapter == nil {
panic("config: Register adapter is 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) panic("config: Register called twice for adapter " + name)
} }
adapters[name] = adapter adapters[name] = adapter

View File

@ -20,13 +20,11 @@ type fakeConfigContainer struct {
} }
func (c *fakeConfigContainer) getData(key string) string { func (c *fakeConfigContainer) getData(key string) string {
key = strings.ToLower(key) return c.data[strings.ToLower(key)]
return c.data[key]
} }
func (c *fakeConfigContainer) Set(key, val string) error { func (c *fakeConfigContainer) Set(key, val string) error {
key = strings.ToLower(key) c.data[strings.ToLower(key)] = val
c.data[key] = val
return nil return nil
} }
@ -55,8 +53,7 @@ func (c *fakeConfigContainer) Float(key string) (float64, error) {
} }
func (c *fakeConfigContainer) DIY(key string) (interface{}, error) { func (c *fakeConfigContainer) DIY(key string) (interface{}, error) {
key = strings.ToLower(key) if v, ok := c.data[strings.ToLower(key)]; ok {
if v, ok := c.data[key]; ok {
return v, nil return v, nil
} }
return nil, errors.New("key not find") return nil, errors.New("key not find")