如何包装redis.Client到我的struct? 我有那个代码并给我一个错误
package main
import (
"github.com/go-redis/redis"
)
var cache *RedisCache
// RedisCache struct
type RedisCache struct {
*redis.Client
}
func initCache() *RedisCache {
if cache == nil {
cache = redis.NewClient(&redis.Options{
Addr: "localhost:6379",
Password: "",
DB: 0,
})
}
return cache
}
cannot use redis.NewClient(&redis.Options literal) (type *redis.Client) as type *RedisCache in assignment
有一些方法可以转换该属性吗?
暮色呼如
相关分类