package config import ( "dcg/pkg/logger" "fmt" c "github.com/gookit/config/v2" "github.com/gookit/config/v2/yaml" ) var Config config type ( Kafka struct { Addr []string Topic string } config struct { // Log 日志配置 Log struct { File logger.FileConfig Console logger.ConsoleConfig } Server struct { Debug bool Listen string } Kafka struct { Danmaku Kafka Gift Kafka } ConsumerGroupId struct { GiftToPush string MsgToPush string MsgToDb string } Command struct { Regex string } } ) 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) }