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 { HikServer hikServer `yaml:"hikServer"` Cameras []model.CameraInfo `yaml:"cameras"` Radars []model.RadarInfo `yaml:"radars"` Screens []model.ScreenInfo `yaml:"screens"` Speakers []model.SpeakerInfo `yaml:"speakers"` Server service `yaml:"service"` } type service struct { SupportRadar bool `yaml:"support_radar"` SupportCamera bool `yaml:"support_camera"` SupportSpeaker bool `yaml:"support_speaker"` SupportLed bool `yaml:"support_led"` } type hikServer struct { Addr string `yaml:"addr"` Path string `yaml:"path"` }