conf.go 594 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package conf
  2. import (
  3. "encoding/json"
  4. "io/ioutil"
  5. )
  6. // Conf info.
  7. var (
  8. Conf *Config
  9. )
  10. // Config struct.
  11. type Config struct {
  12. // httpClinet
  13. HTTPClient *HTTPClient
  14. // host
  15. Host *Host
  16. // Secret
  17. Secret *Secret
  18. }
  19. // HTTPClient conf.
  20. type HTTPClient struct {
  21. Dial int64
  22. KeepAlive int64
  23. }
  24. // Host conf.
  25. type Host struct {
  26. Geetest string
  27. }
  28. // Secret of Geetest
  29. type Secret struct {
  30. CaptchaID string
  31. PrivateKey string
  32. }
  33. // Init conf.
  34. func Init() (err error) {
  35. bs, err := ioutil.ReadFile("config.json")
  36. if err != nil {
  37. return
  38. }
  39. err = json.Unmarshal(bs, &Conf)
  40. return
  41. }