1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-28 23:34:13 +00:00

Merge pull request #1840 from youngsterxyf/develop

To support `go run`
This commit is contained in:
astaxie 2016-03-30 15:46:47 +08:00
commit caa404cec1

View File

@ -116,10 +116,6 @@ var (
) )
func init() { func init() {
AppPath, _ = filepath.Abs(filepath.Dir(os.Args[0]))
os.Chdir(AppPath)
BConfig = &Config{ BConfig = &Config{
AppName: "beego", AppName: "beego",
RunMode: DEV, RunMode: DEV,
@ -180,13 +176,26 @@ func init() {
}, },
} }
appConfigPath = filepath.Join(AppPath, "conf", "app.conf") var err error
if !utils.FileExists(appConfigPath) {
AppConfig = &beegoAppConfig{innerConfig: config.NewFakeConfig()} if AppPath, err = filepath.Abs(filepath.Dir(os.Args[0])); err != nil {
return panic(err)
}
workPath, err := os.Getwd()
if err != nil {
panic(err)
} }
if err := parseConfig(appConfigPath); err != nil { appConfigPath = filepath.Join(workPath, "conf", "app.conf")
if !utils.FileExists(appConfigPath) {
appConfigPath = filepath.Join(AppPath, "conf", "app.conf")
if !utils.FileExists(appConfigPath) {
AppConfig = &beegoAppConfig{innerConfig: config.NewFakeConfig()}
return
}
}
if err = parseConfig(appConfigPath); err != nil {
panic(err) panic(err)
} }
} }