configs.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package configs
  2. //配置文件序列化对象
  3. type Config struct {
  4. Mysql Mysql `mapstructure:"mysql"`
  5. Redis Redis
  6. App App
  7. }
  8. type Mysql struct {
  9. Host string `mapstructure:"host"`
  10. Port int `mapstructure:"port"`
  11. Username string `mapstructure:"username"`
  12. Password string `mapstructure:"password"`
  13. Database string `mapstructure:"database"`
  14. Charset string `mapstructure:"charset"`
  15. }
  16. type Redis struct {
  17. Host string
  18. Password string
  19. Db int64
  20. }
  21. type App struct {
  22. ServerName string `mapstructure:"name"`
  23. Version string `mapstructure:"version"`
  24. InternalAddr string `mapstructure:"internal_addr"`
  25. InternalGrpcAddr string `mapstructure:"internal_grpc_addr"`
  26. Env string `mapstructure:"env"`
  27. LogLevel string `mapstructure:"log_level"`
  28. InternalServicePath string `mapstructure:"internal_service_path"`
  29. MetricAddr string `mapstructure:"metric_path"`
  30. RunModePath string `mapstructure:"runmode_path"`
  31. }
  32. func NewConfig() *Config {
  33. return &Config{}
  34. }