Answer the question
In order to leave comments, you need to log in
How to get test message?
package main
import (
"fmt"
"github.com/go-redis/redis"
)
func main() {
client := redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "", // no password set
DB: 0, // use default DB
})
handlSub(*client)
}
func handlSub(client redis.Client){
sub := client.Subscribe("1_message")
for{
iface, err := sub.Receive()
if err != nil {
fmt.Println(err)
}
// Should be *Subscription, but others are possible if other actions have been
// taken on sub since it was created.
switch iface.(type) {
case *redis.Subscription:
fmt.Println("sub")
case *redis.Message:
fmt.Println(iface)
case *redis.Pong:
fmt.Println("pong")
default:
fmt.Println("err")
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question