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:
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user