package config import ( "fmt" "git.noahlan.cn/northlan/ntools-go/logger" c "github.com/gookit/config/v2" "github.com/gookit/config/v2/yaml" "github.com/zeromicro/go-zero/zrpc" ) var Config config type ( Kafka struct { Addr []string Topic string ConsumerGroup string } Game struct { // Commands 命令列表 Commands []string } config struct { // Log 日志配置 Log struct { File logger.FileConfig Console logger.ConsoleConfig } Server struct { Debug bool Listen string } // Kafka 队列配置 Kafka struct { Danmaku Kafka Gift Kafka } Game struct { // 通用模式 Common struct { Commands []string } // Zhg 指挥官PvP模式 Zhg struct { Commands []string OutbreakCount int64 // 每次暴兵数量 OutbreakBaseCost int64 // 默认每次暴兵消耗积分(不限兵种) OutbreakCostDict map[int]int64 // 暴兵消耗积分表 } Zhghz Game // 指挥官海战模式 Zhgfb Game // 指挥官副本模式 } // RPC UserCenterRpc zrpc.RpcClientConf } ) func Init(filepath string) { var err error c.AddDriver(yaml.Driver) err = c.LoadFiles(filepath) if err != nil { panic(err) } err = c.BindStruct("", &Config) if err != nil { panic(err) } fmt.Printf("%+v\n", Config) }