23 lines
444 B
Go

package config
import "fmt"
// RedisConfig 是Redis相关配置
type RedisConfig struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
Password string `mapstructure:"password"`
DB int `mapstructure:"db"`
}
// Validate 验证Redis配置
func (r *RedisConfig) Validate() error {
if r.Host == "" {
return fmt.Errorf("redis主机不能为空")
}
if r.Port <= 0 {
r.Port = 6379
}
return nil
}