From d1481ea659253f6f66bae053fd358f66c68f384c Mon Sep 17 00:00:00 2001 From: coseyo Date: Mon, 25 Jan 2016 23:00:09 +0800 Subject: [PATCH] move assignment to init --- config.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/config.go b/config.go index 3ceae12e..bf9077a7 100644 --- a/config.go +++ b/config.go @@ -113,9 +113,15 @@ var ( TemplateCache map[string]*template.Template // GlobalSessions is the instance for the session manager GlobalSessions *session.Manager + + workPath string ) func init() { + AppPath, _ = filepath.Abs(filepath.Dir(os.Args[0])) + workPath, _ = os.Getwd() + workPath, _ = filepath.Abs(workPath) + BConfig = &Config{ AppName: "beego", RunMode: DEV, @@ -181,10 +187,6 @@ func init() { // ParseConfig parsed default config file. // now only support ini, next will support json. func ParseConfig() (err error) { - AppPath, _ := filepath.Abs(filepath.Dir(os.Args[0])) - workPath, _ := os.Getwd() - workPath, _ = filepath.Abs(workPath) - if AppConfigPath == "" { // initialize default configurations AppConfigPath = filepath.Join(AppPath, "conf", "app.conf")