config.go 994 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package util
  2. import (
  3. "github.com/sirupsen/logrus"
  4. "gopkg.in/yaml.v3"
  5. "lc-smartX/lc/model"
  6. "os"
  7. )
  8. var Config = func() config {
  9. var conf config
  10. file, err := os.ReadFile("./config.yaml")
  11. if err != nil {
  12. logrus.Fatal("配置文件读取失败! error:", err)
  13. }
  14. err = yaml.Unmarshal(file, &conf)
  15. if err != nil {
  16. logrus.Fatal("配置文件解析失败! error:", err)
  17. }
  18. return conf
  19. }()
  20. type config struct {
  21. HikServer hikServer `yaml:"hikServer"`
  22. Cameras []model.CameraInfo `yaml:"cameras"`
  23. Radars []model.RadarInfo `yaml:"radars"`
  24. Screens []model.ScreenInfo `yaml:"screens"`
  25. Speakers []model.SpeakerInfo `yaml:"speakers"`
  26. Server service `yaml:"service"`
  27. }
  28. type service struct {
  29. SupportRadar bool `yaml:"support_radar"`
  30. SupportCamera bool `yaml:"support_camera"`
  31. SupportSpeaker bool `yaml:"support_speaker"`
  32. SupportLed bool `yaml:"support_led"`
  33. }
  34. type hikServer struct {
  35. Addr string `yaml:"addr"`
  36. Path string `yaml:"path"`
  37. }