| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package util
- import (
- "github.com/sirupsen/logrus"
- "gopkg.in/yaml.v3"
- "lc-smartX/lc/model"
- "os"
- )
- var Config = func() config {
- var conf config
- file, err := os.ReadFile("./config.yaml")
- if err != nil {
- logrus.Fatal("配置文件读取失败! error:", err)
- }
- err = yaml.Unmarshal(file, &conf)
- if err != nil {
- logrus.Fatal("配置文件解析失败! error:", err)
- }
- return conf
- }()
- type config struct {
- Cameras []model.CameraInfo `yaml:"cameras"`
- Radars []model.RadarInfo `yaml:"radars"`
- Screens []model.ScreenInfo `yaml:"screens"`
- Speakers []model.SpeakerInfo `yaml:"speakers"`
- Server server `yaml:"server"`
- RedisConfig RedisConfig `yaml:"redis"`
- }
- type server struct {
- SupportRadar bool `yaml:"supportRadar"`
- SupportCamera bool `yaml:"supportCamera"`
- HikServer hikServer `yaml:"hikServer"`
- }
- type hikServer struct {
- Addr string `yaml:"addr"`
- Path string `yaml:"path"`
- }
- type RedisConfig struct {
- Addr string `yaml:"addr"`
- Password string `yaml:"password"`
- DB int `yaml:"db"`
- }
|