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 { Zhg Game // 指挥官PvP模式 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) }