fix handle error redis

This commit is contained in:
pakintada@gmail.com 2024-02-08 13:58:11 +07:00
parent 679c7f85bf
commit fb046dadf8

View file

@ -26,7 +26,7 @@ func NewRedisClient(address, password string) *RedisCli {
client := redis.NewClient(&options) client := redis.NewClient(&options)
if err := client.Ping(context.Background()); err != nil { if err := client.Ping(context.Background()); err.Err() != nil {
fmt.Println("trying localhost ...", err) fmt.Println("trying localhost ...", err)
client = redis.NewClient(&redis.Options{ client = redis.NewClient(&redis.Options{
Addr: "localhost:6379", Addr: "localhost:6379",
@ -34,7 +34,7 @@ func NewRedisClient(address, password string) *RedisCli {
DB: 0, DB: 0,
}) })
if err_local := client.Ping(context.Background()); err_local != nil { if err_local := client.Ping(context.Background()); err_local.Err() != nil {
fmt.Println("> result ====> ", err_local) fmt.Println("> result ====> ", err_local)
// do as warning // do as warning
} else { } else {