1
0
mirror of https://github.com/astaxie/beego.git synced 2024-06-28 05:54:14 +00:00

To support go run

This commit is contained in:
youngsterxyf 2016-03-29 18:16:38 +08:00
parent 220cf91180
commit 561e7115f3

View File

@ -106,6 +106,8 @@ var (
AppConfig *beegoAppConfig AppConfig *beegoAppConfig
// AppPath is the absolute path to the app // AppPath is the absolute path to the app
AppPath string AppPath string
// workPath is the absolute path of the current dir
workPath string
// GlobalSessions is the instance for the session manager // GlobalSessions is the instance for the session manager
GlobalSessions *session.Manager GlobalSessions *session.Manager
@ -118,7 +120,8 @@ var (
func init() { func init() {
AppPath, _ = filepath.Abs(filepath.Dir(os.Args[0])) AppPath, _ = filepath.Abs(filepath.Dir(os.Args[0]))
os.Chdir(AppPath) workPath, _ = os.Getwd()
workPath, _ = filepath.Abs(workPath)
BConfig = &Config{ BConfig = &Config{
AppName: "beego", AppName: "beego",
@ -180,10 +183,13 @@ func init() {
}, },
} }
appConfigPath = filepath.Join(AppPath, "conf", "app.conf") appConfigPath = filepath.Join(workPath, "conf", "app.conf")
if !utils.FileExists(appConfigPath) { if !utils.FileExists(appConfigPath) {
AppConfig = &beegoAppConfig{innerConfig: config.NewFakeConfig()} appConfigPath = filepath.Join(AppPath, "conf", "app.conf")
return if !utils.FileExists(appConfigPath) {
AppConfig = &beegoAppConfig{innerConfig: config.NewFakeConfig()}
return
}
} }
if err := parseConfig(appConfigPath); err != nil { if err := parseConfig(appConfigPath); err != nil {