From 8330316dda9b44334650c4e0ccd2fb80191ade43 Mon Sep 17 00:00:00 2001 From: Brabem <2198702716@qq.com> Date: Tue, 6 Feb 2024 18:58:23 +0800 Subject: [PATCH] fix: fix the InitConfig error --- pkg/common/config/parse.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pkg/common/config/parse.go b/pkg/common/config/parse.go index 074b7771a..4037429e3 100644 --- a/pkg/common/config/parse.go +++ b/pkg/common/config/parse.go @@ -17,7 +17,6 @@ package config import ( _ "embed" "fmt" - "github.com/OpenIMSDK/tools/errs" "os" "path/filepath" @@ -85,26 +84,25 @@ func GetOptionsByNotification(cfg NotificationConf) msgprocessor.Options { } func initConfig(config any, configName, configFolderPath string) error { - configFullPath := filepath.Join(configFolderPath, configName) - _, err := os.Stat(configFullPath) + configFolderPath = filepath.Join(configFolderPath, configName) + _, err := os.Stat(configFolderPath) if err != nil { if !os.IsNotExist(err) { - return errs.Wrap(err, "IsNotExist "+configFolderPath) + fmt.Println("stat config path error:", err.Error()) + return fmt.Errorf("stat config path error: %w", err) } configFolderPath = filepath.Join(GetProjectRoot(), "config", configName) - errs.Wrap(fmt.Errorf("flag's path,enviment's path,default path all is not exist,using project path:%s", configFolderPath)) + fmt.Println("flag's path,enviment's path,default path all is not exist,using project path:", configFolderPath) } data, err := os.ReadFile(configFolderPath) if err != nil { - return errs.Wrap(err, "readFile failed, "+configFolderPath) + return fmt.Errorf("read file error: %w", err) } if err = yaml.Unmarshal(data, config); err != nil { - return errs.Wrap(err, "unmarshal yaml failed, "+configFolderPath) + return fmt.Errorf("unmarshal yaml error: %w", err) } - fmt.Println("The path of the configuration file to start the process:", configFolderPath) - return nil }