1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-12 00:11:02 +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

@ -42,11 +42,13 @@ needlogin = ON
enableSession = Y
enableCookie = N
flag = 1
path = $ENV_GOROOT
[demo]
key1="asta"
key2 = "xie"
CaseInsensitive = true
peers = one;two;three
password = $ENV_GOROOT
`
keyValue = map[string]interface{}{
@ -64,10 +66,12 @@ peers = one;two;three
"enableSession": true,
"enableCookie": false,
"flag": true,
"path": os.Getenv("GOROOT"),
"demo::key1": "asta",
"demo::key2": "xie",
"demo::CaseInsensitive": true,
"demo::peers": []string{"one", "two", "three"},
"demo::password": os.Getenv("GOROOT"),
"null": "",
"demo2::key1": "",
"error": "",
@ -140,6 +144,7 @@ httpport = 8080
# db type name
# suport mysql,sqlserver
name = mysql
path = $ENV_GOROOT
`
saveResult = `
@ -156,6 +161,7 @@ httpport=8080
# db type name
# suport mysql,sqlserver
name=mysql
path=$ENV_GOROOT
`
)
cfg, err := NewConfigData("ini", []byte(inicontext))