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.

54 lines
999 B
Go

3 years ago
package config
import (
"fmt"
"git.noahlan.cn/northlan/ntools-go/logger"
c "github.com/gookit/config/v2"
"github.com/gookit/config/v2/yaml"
"time"
)
3 years ago
var Config config
type (
Kafka struct {
Addr []string
Topic string
}
config struct {
Bilibili struct {
Url string // 弹幕服务器url
GetRoomUrl string // 获取房间信息url
RoomId int64 // 待连接roomId
UserId int64 // 用于连接的userId,0则随机生成
HeartbeatInterval time.Duration // 心跳间隔 单位s
}
// Log 日志配置
Log struct {
File logger.FileConfig
Console logger.ConsoleConfig
}
// Kafka 队列配置
Kafka struct {
Danmaku Kafka
Gift Kafka
}
}
)
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)
3 years ago
}