From b9c8c08c035ff61ae95f4d776f585cf569129592 Mon Sep 17 00:00:00 2001 From: Abel Date: Thu, 26 Oct 2017 19:25:05 +0800 Subject: [PATCH 1/3] Add host env feature. --- config.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index e6e99570..4598bda5 100644 --- a/config.go +++ b/config.go @@ -134,9 +134,16 @@ func init() { if err != nil { panic(err) } - appConfigPath = filepath.Join(workPath, "conf", "app.conf") + var confFile = "app." + var hostEnv = os.Getenv("BEEGO_ENV") + if (len(hostEnv) != 0){ + confFile += hostEnv+".conf" + }else{ + confFile += "conf" + } + appConfigPath = filepath.Join(workPath, "conf", confFile) if !utils.FileExists(appConfigPath) { - appConfigPath = filepath.Join(AppPath, "conf", "app.conf") + appConfigPath = filepath.Join(AppPath, "conf", confFile) if !utils.FileExists(appConfigPath) { AppConfig = &beegoAppConfig{innerConfig: config.NewFakeConfig()} return From 229d8b953033add2508dde6b8c14ff5b8f4bf044 Mon Sep 17 00:00:00 2001 From: Abel Date: Mon, 30 Oct 2017 13:54:36 +0800 Subject: [PATCH 2/3] Add host env feature. --- config.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/config.go b/config.go index 4598bda5..d51a1665 100644 --- a/config.go +++ b/config.go @@ -134,16 +134,13 @@ func init() { if err != nil { panic(err) } - var confFile = "app." - var hostEnv = os.Getenv("BEEGO_ENV") - if (len(hostEnv) != 0){ - confFile += hostEnv+".conf" - }else{ - confFile += "conf" - } - appConfigPath = filepath.Join(workPath, "conf", confFile) + var filename = "app.conf" + if os.Getenv("BEEGO_MODE") !=""{ + filename= os.Getenv("BEEGO_MODE")+".app.conf" + } + appConfigPath = filepath.Join(workPath, "conf", filename) if !utils.FileExists(appConfigPath) { - appConfigPath = filepath.Join(AppPath, "conf", confFile) + appConfigPath = filepath.Join(AppPath, "conf", filename) if !utils.FileExists(appConfigPath) { AppConfig = &beegoAppConfig{innerConfig: config.NewFakeConfig()} return From 3504d2a4dab810a8f70878f1410a0f17f193ad5d Mon Sep 17 00:00:00 2001 From: Abel Date: Tue, 31 Oct 2017 19:19:14 +0800 Subject: [PATCH 3/3] Add host env feature. --- config.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config.go b/config.go index d51a1665..ac0a0615 100644 --- a/config.go +++ b/config.go @@ -134,10 +134,10 @@ func init() { if err != nil { panic(err) } - var filename = "app.conf" - if os.Getenv("BEEGO_MODE") !=""{ - filename= os.Getenv("BEEGO_MODE")+".app.conf" - } + var filename = "app.conf" + if os.Getenv("BEEGO_MODE") != "" { + filename = os.Getenv("BEEGO_MODE") + ".app.conf" + } appConfigPath = filepath.Join(workPath, "conf", filename) if !utils.FileExists(appConfigPath) { appConfigPath = filepath.Join(AppPath, "conf", filename)