1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-06 01:40:18 +00:00

Config support get environment variable

get environment variable if config item  has prefix "$ENV_" .
e.g.
```ini
[demo]
password = $ENV_MyPWD
```
This commit is contained in:
ysqi
2016-01-27 20:46:30 +08:00
parent 4ce094a29a
commit cd31c816cc
10 changed files with 222 additions and 32 deletions

View File

@ -250,11 +250,18 @@ func (c *JSONConfigContainer) getData(key string) interface{} {
}
}
}
if env, ok := Getenv(curValue); ok {
return env
}
return curValue
}
if v, ok := c.data[key]; ok {
if env, ok := Getenv(v); ok {
return env
}
return v
}
return nil
}