How to get the message 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)
}

handlSub func(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.
 iface switch.(type) {
 case *redis.Subscription:
fmt.Println("sub")
 case *redis.Message:
fmt.Println(iface)
 case *redis.Pong:
fmt.Println("pong")
default:
fmt.Println("err")
}
}
}

redis-to-go returns a message in this format. How to receive a message (test)?
Message<1_message: test>
March 23rd 20 at 19:46
0 answer

Find more questions by tags Go