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.

54 lignes
965B

  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. return readConfigFile("config.json")
  22. }
  23. func readConfigFile(file string) error {
  24. log.Printf("Read configration from %s", file)
  25. body, err := ioutil.ReadFile(file)
  26. if err != nil {
  27. log.Fatal("Fatal error Cannot read config ..")
  28. return err
  29. }
  30. err = json.Unmarshal(body, &Config)
  31. if err != nil {
  32. log.Fatal("cannot read config into json")
  33. return err
  34. }
  35. j, err := json.MarshalIndent(Config, "", "\t")
  36. if err != nil {
  37. log.Fatal("cannot print back to json")
  38. return err
  39. }
  40. fmt.Println(string(j))
  41. return err
  42. }
  43. func readConfigForTest() error {
  44. return readConfigFile("config.test.json")
  45. }