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.

64 lines
893 B
Go

package config
import (
"dcg/pkg/logger"
"fmt"
c "github.com/gookit/config/v2"
"github.com/gookit/config/v2/yaml"
"path/filepath"
"runtime"
)
var (
_, b, _, _ = runtime.Caller(0)
Root = filepath.Join(filepath.Dir(b), "../")
)
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 {
MsgToPush string
MsgToDb string
}
Command struct {
Regex string
}
}
)
func init() {
var err error
c.AddDriver(yaml.Driver)
err = c.LoadFiles(Root + "/config.yml")
if err != nil {
panic(err)
}
err = c.BindStruct("", &Config)
if err != nil {
panic(err)
}
fmt.Printf("%+v\n", Config)
}