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"` Screens []model.ScreenInfo `yaml:"screens"` Server service `yaml:"service"` Mqtt MqttConfig `yaml:"mqtt"` } type MqttConfig struct { Server string `json:"server"` User string `json:"user"` Password string `json:"password"` Timeout uint `json:"timeout"` } type service struct { SupportCamera bool `yaml:"support_camera"` SupportLed bool `yaml:"support_led"` } type hikServer struct { Addr string `yaml:"addr"` Path string `yaml:"path"` }