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