1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-26 03:14:14 +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() {
AppPath, _ = filepath.Abs(filepath.Dir(os.Args[0]))
os.Chdir(AppPath)
BConfig = &Config{
AppName: "beego",
RunMode: DEV,
@ -180,13 +176,26 @@ func init() {
},
}
appConfigPath = filepath.Join(AppPath, "conf", "app.conf")
if !utils.FileExists(appConfigPath) {
AppConfig = &beegoAppConfig{innerConfig: config.NewFakeConfig()}
return
var err error
if AppPath, err = filepath.Abs(filepath.Dir(os.Args[0])); err != nil {
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)
}
}