This commit is contained in:
2025-08-04 10:49:24 +08:00
parent 84ccaa56de
commit 4b1eb11986
11 changed files with 194 additions and 72 deletions

View File

@@ -1,8 +1,9 @@
package config
import (
"ZhenTuLocalPassiveAdapter/logger"
"github.com/spf13/viper"
"log"
"go.uber.org/zap"
)
var Config MainConfig
@@ -14,13 +15,13 @@ func LoadConfig() error {
// 读取配置文件
if err := viper.ReadInConfig(); err != nil {
log.Fatalf("Error reading config file, %s", err)
logger.Fatal("读取配置文件失败", zap.Error(err))
return err
}
// 反序列化配置到结构体
if err := viper.Unmarshal(&Config); err != nil {
log.Fatalf("Unable to decode into struct, %v", err)
logger.Fatal("解析配置失败", zap.Error(err))
return err
}
return nil