config.go 749 B

123456789101112131415161718192021222324252627282930313233343536
  1. package service
  2. import (
  3. "github.com/BurntSushi/toml"
  4. )
  5. type Config struct {
  6. WebAddr string `toml:"WebAddr"`
  7. WebIndex string `toml: "WebIndex"`
  8. REFRESH_TOKENS string `toml: "REFRESH_TOKENS"`
  9. PUSHPLUS_TOKEN string `toml: "PUSHPLUS_TOKEN"`
  10. EmailUser string `toml: "EmailUser"`
  11. EmailPwd string `toml: "EmailPwd"`
  12. EmailSmtp string `toml: "EmailSmtp"`
  13. EmailTls bool `toml: "EmailTls"`
  14. Username string `toml:"Username"`
  15. Password string `toml:"Password"`
  16. }
  17. var config *Config
  18. func LoadConfig(path string) *Config {
  19. conf := &Config{}
  20. _, err := toml.DecodeFile(path, conf)
  21. if err != nil {
  22. panic(err)
  23. }
  24. config = conf
  25. logger.Info(config)
  26. return config
  27. }
  28. // todo
  29. func saveConfig() {
  30. }