You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 satır
906B

  1. package main
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "io/ioutil"
  6. "log"
  7. )
  8. //PathsConfig all system available pathes
  9. type PathsConfig struct {
  10. Angular2App string `json:"angular2_app"`
  11. SinglePageEdit string `json:"singlePageEdit"`
  12. ThisSiteURL string `json:"thisSiteURL"`
  13. }
  14. //GlobalPath all global pathes configurations
  15. var GlobalPath = PathsConfig{}
  16. func (m *PathsConfig) readConfig() error {
  17. log.Printf("read Path config from %s\r\n", "path_config.json")
  18. body, err := ioutil.ReadFile("path_config.json")
  19. if err != nil {
  20. log.Fatal("Cannot read config from path_config.json")
  21. return err
  22. }
  23. err = json.Unmarshal(body, m)
  24. if m.SinglePageEdit == "" {
  25. return errors.New("Single Page Edit Resources not available")
  26. }
  27. if m.Angular2App == "" {
  28. return errors.New("Angular2APP path not available")
  29. }
  30. if m.ThisSiteURL == "" {
  31. return errors.New("site url not available")
  32. }
  33. return err
  34. }