From 7f575be6baed5ac86df8ad085a5c7665c975ae93 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 27 Apr 2024 18:31:48 +0800 Subject: [PATCH] :art: Improve load conf --- kernel/model/conf.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/model/conf.go b/kernel/model/conf.go index 1dbdd26e4..104863088 100644 --- a/kernel/model/conf.go +++ b/kernel/model/conf.go @@ -115,13 +115,14 @@ func InitConf() { Conf = &AppConf{LogLevel: "debug", m: &sync.Mutex{}} confPath := filepath.Join(util.ConfDir, "conf.json") if gulu.File.IsExist(confPath) { - data, err := os.ReadFile(confPath) - if nil != err { + if data, err := os.ReadFile(confPath); nil != err { logging.LogErrorf("load conf [%s] failed: %s", confPath, err) - } - err = gulu.JSON.UnmarshalJSON(data, Conf) - if err != nil { - logging.LogErrorf("parse conf [%s] failed: %s", confPath, err) + } else { + if err = gulu.JSON.UnmarshalJSON(data, Conf); err != nil { + logging.LogErrorf("parse conf [%s] failed: %s", confPath, err) + } else { + logging.LogInfof("loaded conf [%s]", confPath) + } } }