1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-15 09:30:41 +00:00

modify struct

This commit is contained in:
xiemengjun
2012-03-07 20:30:33 +08:00
parent 9fdad84fd0
commit d736ac450a
12 changed files with 0 additions and 0 deletions

28
beego/helper/config.go Normal file
View File

@ -0,0 +1,28 @@
package helper
import (
"json"
"io/ioutil"
"log"
)
var config map[string]string
func ReadConfig(filename string) {
contents, err := ioutil.ReadFile(filename)
if err != nil {
log.Exitf("Impossible to read %s", filename, err)
}
data, err := json.Decode(string(contents))
if err != nil {
log.Exitf("Can't parse %s as JSON", filename, err)
}
config = map[string]string{ }
for key, value := range data.(map[string]interface{ }) {
config[key] = value.(string)
}
}
func GetConfig(key string) string {
return config[key];
}

0
beego/helper/page.go Normal file
View File