Эх сурвалжийг харах

修改 方法名称和方法

fly 1 жил өмнө
parent
commit
52288b0753
2 өөрчлөгдсөн 9 нэмэгдсэн , 8 устгасан
  1. 4 4
      config/config.go
  2. 5 4
      config/object.go

+ 4 - 4
config/config.go

@@ -59,15 +59,15 @@ func Set(module, key string, value any) {
 	viper.Set(module+"."+key, value)
 }
 
-func IsExistConfigFile() bool {
+func ReadConfigAndFileExist() (bool, error) {
 	if err := viper.ReadInConfig(); err != nil {
 		if _, ok := err.(viper.ConfigFileNotFoundError); ok {
 			// 配置文件未找到
-			return true
+			return false, nil
 		} else {
 			// 其他错误
-			return false
+			return true, err
 		}
 	}
-	return false
+	return true, nil
 }

+ 5 - 4
config/object.go

@@ -63,15 +63,16 @@ func (c *config) GetStringSlice(module string, key string) []string {
 func (c *config) Set(module, key string, value any) {
 	c.Viper.Set(module+"."+key, value)
 }
-func (c *config) IsExistConfigFile() bool {
+
+func (c *config) ReadConfigAndFileExist() (bool, error) {
 	if err := c.Viper.ReadInConfig(); err != nil {
 		if _, ok := err.(viper.ConfigFileNotFoundError); ok {
 			// 配置文件未找到
-			return true
+			return false, nil
 		} else {
 			// 其他错误
-			return false
+			return true, err
 		}
 	}
-	return false
+	return true, nil
 }