payment gateway for rpn cn
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

56 lignes
1.0KB

  1. package main
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "io/ioutil"
  6. "log"
  7. )
  8. type AppConfig struct {
  9. Rpn struct {
  10. Url string `json:Url`
  11. UrlTest string `json:UrlTest`
  12. MD5P2P string `json:MD5P2P`
  13. MD5FAT string `json:MD5FAT`
  14. } `json:Rpn`
  15. LeanWork struct {
  16. MD5Key string `json:MD5Key`
  17. } `json:LeanWork`
  18. }
  19. var Config AppConfig
  20. func readConfig() error {
  21. log.Println("Read configration for production ")
  22. return readConfigFile("config.json")
  23. }
  24. func readConfigForTest() error {
  25. log.Println("Read configration for Test ")
  26. return readConfigFile("config.test.json")
  27. }
  28. func readConfigFile(file string) error {
  29. log.Printf("Read configration from %s", file)
  30. body, err := ioutil.ReadFile(file)
  31. if err != nil {
  32. log.Fatal("Fatal error Cannot read config ..")
  33. return err
  34. }
  35. err = json.Unmarshal(body, &Config)
  36. if err != nil {
  37. log.Fatal("cannot read config into json")
  38. return err
  39. }
  40. j, err := json.MarshalIndent(Config, "", "\t")
  41. if err != nil {
  42. log.Fatal("cannot print back to json")
  43. return err
  44. }
  45. fmt.Println(string(j))
  46. return err
  47. }