|
@@ -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
|
|
|
}
|