func listenForMessages(p *redis.PubSub, chat chan string) {
	for {
		m, err := p.ReceiveMessage()
		if err != nil {
			panic(err)
		} else {
			chat <- m.Payload
		}
	}
}
Receive messages in the pub/sub model
package main
import (
	"bufio"
	"context"
	"flag"
	"fmt"
	"log"
	"os"
	"os/signal"
	"syscall"
	pb "github.com/clarencejychan/consolechat-grpc/console-chat"
	"github.com/go-redis/redis"
	"google.golang.org/grpc"
)
var (
	user       = ""
	redisAddr  = "localhost:6379"
	serverAddr = flag.String("server_addr", "localhost:3000", "The server address in the format of host:port")
)
func initRedis(addr string) (*redis.Client, error) {
	redisClient := redis.NewClient(&redis.Options{
		Addr:     addr,
		Password: "",  
		DB:       0,   
	})
	_, err := redisClient.Ping().Result()
	if err != nil {
		return nil, err
	}
	fmt.Println("Listening to redis on 6379")
	return redisClient, nil
}