1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-12 16:20:39 +00:00

Change key format

key format : ${ENV_PART||defaultValue} or  ${ENV_PART}
This commit is contained in:
ysqi
2016-03-29 21:47:33 +08:00
parent 5bd7d8c43f
commit 7e65338c87
10 changed files with 105 additions and 93 deletions

View File

@ -69,7 +69,7 @@ func (xc *Config) Parse(filename string) (config.Configer, error) {
return nil, err
}
x.data = config.ChooseRealValueForMap(d["config"].(map[string]interface{}))
x.data = config.ExpandValueEnvForMap(d["config"].(map[string]interface{}))
return x, nil
}

View File

@ -35,14 +35,8 @@ func TestXML(t *testing.T) {
<runmode>dev</runmode>
<autorender>false</autorender>
<copyrequestbody>true</copyrequestbody>
<path1>$$GOPATH</path1>
<path2>$$GOPATH||/home/go</path2>
<path3>$$GOPATH$$GOPATH2||/home/go</path3>
<token1>$$TOKEN</token1>
<token2>$$TOKEN||</token2>
<token3>$$TOKEN||astaxie</token3>
<token4>token$$TOKEN</token4>
<token5>$$TOKEN$$TOKEN||TOKEN</token5>
<path1>${GOPATH}</path1>
<path2>${GOPATH||/home/go}</path2>
</config>
`
keyValue = map[string]interface{}{
@ -55,12 +49,6 @@ func TestXML(t *testing.T) {
"copyrequestbody": true,
"path1": os.Getenv("GOPATH"),
"path2": os.Getenv("GOPATH"),
"path3": "/home/go",
"token1": "",
"token2": "",
"token3": "astaxie",
"token4": "token$$TOKEN",
"token5": "TOKEN",
"error": "",
"emptystrings": []string{},
}