How to GO to make a regular subscription to a channel in Redis?

Hello, actually a subject

package main

import (
"fmt"
"github.com/go-redis/redis"
)

func main() {

 client := redis.NewClient(&redis.Options{
 Addr: "localhost:6379",
 Password: "",
 DB: 0,
})

 pubsub := client.Subscribe("test")
 defer pubsub.Close()
 msg, err := pubsub.ReceiveMessage()
 if err != nil {
panic(err)
}
 fmt.Println(msg.Channel, msg.Payload)
}


How is it to get to work constantly, not be completed after the first value is placed in the channel?
March 30th 20 at 00:43
1 answer
March 30th 20 at 00:45
To use pubsub.Channel() and to read from a channel in a cycle. In the documentation there is an example.
@jovanny, create issue on github. - Marlen_Hickle commented on March 30th 20 at 00:48

Find more questions by tags RedisGo