From 31ef4ae507cf3395cb61dc2c96d5416b7695b3df Mon Sep 17 00:00:00 2001 From: youngsterxyf Date: Wed, 27 Jan 2016 16:43:01 +0800 Subject: [PATCH] rename AppConfigPath, AppConfigProvider to appConfigPath, appConfigProvider, make public to private --- admin.go | 4 ++-- beego.go | 2 +- config.go | 30 +++++++++++++++--------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/admin.go b/admin.go index 3effc582..031e6421 100644 --- a/admin.go +++ b/admin.go @@ -90,8 +90,8 @@ func listConf(rw http.ResponseWriter, r *http.Request) { switch command { case "conf": m := make(map[string]interface{}) - m["AppConfigPath"] = AppConfigPath - m["AppConfigProvider"] = AppConfigProvider + m["AppConfigPath"] = appConfigPath + m["AppConfigProvider"] = appConfigProvider m["BConfig.AppName"] = BConfig.AppName m["BConfig.RunMode"] = BConfig.RunMode m["BConfig.RouterCaseSensitive"] = BConfig.RouterCaseSensitive diff --git a/beego.go b/beego.go index 65368295..fb628e5f 100644 --- a/beego.go +++ b/beego.go @@ -85,7 +85,7 @@ func initBeforeHTTPRun() { // TestBeegoInit is for test package init func TestBeegoInit(ap string) { os.Setenv("BEEGO_RUNMODE", "test") - AppConfigPath = filepath.Join(ap, "conf", "app.conf") + appConfigPath = filepath.Join(ap, "conf", "app.conf") os.Chdir(ap) initBeforeHTTPRun() } diff --git a/config.go b/config.go index e0439084..7e2b3ee7 100644 --- a/config.go +++ b/config.go @@ -106,16 +106,16 @@ var ( AppConfig *beegoAppConfig // AppPath is the absolute path to the app AppPath string - // AppConfigPath is the path to the config files - AppConfigPath string - // AppConfigProvider is the provider for the config, default is ini - AppConfigProvider = "ini" // TemplateCache stores template caching TemplateCache map[string]*template.Template // GlobalSessions is the instance for the session manager GlobalSessions *session.Manager workPath string + // appConfigPath is the path to the config files + appConfigPath string + // appConfigProvider is the provider for the config, default is ini + appConfigProvider = "ini" ) func init() { @@ -187,18 +187,18 @@ func init() { }, } - AppConfigPath = filepath.Join(AppPath, "conf", "app.conf") - if !utils.FileExists(AppConfigPath) { + appConfigPath = filepath.Join(AppPath, "conf", "app.conf") + if !utils.FileExists(appConfigPath) { AppConfig = &beegoAppConfig{config.NewFakeConfig()} return } - parseConfig(AppConfigPath) + parseConfig(appConfigPath) } // now only support ini, next will support json. func parseConfig(appConfigPath string) (err error) { - AppConfig, err = newAppConfig(AppConfigProvider, appConfigPath) + AppConfig, err = newAppConfig(appConfigProvider, appConfigPath) if err != nil { return err } @@ -312,7 +312,7 @@ func parseConfig(appConfigPath string) (err error) { } // LoadAppConfig allow developer to apply a config file -func LoadAppConfig(adapterName string, configPath string) error { +func LoadAppConfig(adapterName, configPath string) error { absConfigPath, err := filepath.Abs(configPath) if err != nil { return err @@ -322,22 +322,22 @@ func LoadAppConfig(adapterName string, configPath string) error { return fmt.Errorf("the target config file: %s don't exist!", configPath) } - if absConfigPath == AppConfigPath { + if absConfigPath == appConfigPath { return nil } - AppConfigPath = absConfigPath - AppConfigProvider = adapterName + appConfigPath = absConfigPath + appConfigProvider = adapterName - return parseConfig(AppConfigPath) + return parseConfig(appConfigPath) } type beegoAppConfig struct { innerConfig config.Configer } -func newAppConfig(AppConfigProvider, AppConfigPath string) (*beegoAppConfig, error) { - ac, err := config.NewConfig(AppConfigProvider, AppConfigPath) +func newAppConfig(appConfigProvider, appConfigPath string) (*beegoAppConfig, error) { + ac, err := config.NewConfig(appConfigProvider, appConfigPath) if err != nil { return nil, err }