草庐IT

ICacheEngine

全部标签

go - 如何将结构分配给接口(interface)

这是我的代码:typeICacheEngineinterface{//...}//implementsallmethodsofICacheEnginetypeRedisCachestruct{}typeApplicationCachestruct{Cache*ICacheEngine}funcNewRedisCache()*ApplicationCache{appCache:=new(ApplicationCache)redisCache:=new(RedisCache)appCache.Cache=redisCache//hereisanerror:cannotuse*RedisCa

go - 如何将结构分配给接口(interface)

这是我的代码:typeICacheEngineinterface{//...}//implementsallmethodsofICacheEnginetypeRedisCachestruct{}typeApplicationCachestruct{Cache*ICacheEngine}funcNewRedisCache()*ApplicationCache{appCache:=new(ApplicationCache)redisCache:=new(RedisCache)appCache.Cache=redisCache//hereisanerror:cannotuse*RedisCa