package global import ( "Ic_ouath/configs" "Ic_ouath/simple_zap" "context" "github.com/go-redis/redis/v8" ) var Rdb *redis.Client func SetupRedisLink() { //addr := RedisSetting.Addr //password := RedisSetting.Password //db := RedisSetting.DB Rdb = redis.NewClient(&redis.Options{ Addr: configs.Config.GetString("redis.addr"), Password: "", DB: 0, }) ctx := context.Background() _, err := Rdb.Ping(ctx).Result() if err != nil { simple_zap.WithCtx(context.Background()).Sugar().Warn("redis连接失败", err) } }