package global import ( "Panel_development/configs" "Panel_development/simple_zap" "context" "fmt" "github.com/go-redis/redis/v8" ) var Rdb *redis.Client func SetupRedisLink() { Rdb = redis.NewClient(&redis.Options{ Addr: configs.Config.GetString("redis.addr"), Password: "", DB: 0, }) ctx := context.Background() _, err := Rdb.Ping(ctx).Result() if err != nil { simple_zap.WithCtx(context.Background()).Sugar().Warn("redis连接失败", err) fmt.Println(err) } }