You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
907 B
Go
62 lines
907 B
Go
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
|
|
}
|
|
|
|
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 {
|
|
Keys []string
|
|
}
|
|
|
|
// 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)
|
|
}
|