fix handle error redis
This commit is contained in:
parent
679c7f85bf
commit
fb046dadf8
1 changed files with 2 additions and 2 deletions
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue