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"` Radios []model.RadioInfo `yaml:"radios"` Screens []model.ScreenInfo `yaml:"screens"` Speakers []model.SpeakerInfo `yaml:"speakers"` Server service `yaml:"service"` } type service struct { SupportRadio bool `yaml:"support_radio"` 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"` }