On Fri, May 7, 2021 at 11:08 AM Viet Nguyen <
afe...@gmail.com> wrote:
>
> I'm trying to convert this code to use generics:
>
> type Cache interface {
> GetIfPresent(interface{}) (interface{}, bool)
> }
>
> type LoadingCache interface {
> Cache
> Get(interface{}) (interface{}, error)
> }
>
> However, I couldn't find any way to include Cache[K, V] in LoadingCache[K, V]. (No similar use cases in the proposal? I must miss something here). The workaround is copying all methods over, like:
>
> type Cache[K comparable, V any] interface {
> GetIfPresent(K) (V, bool)
> }
>
> type LoadingCache[K comparable, V any] interface {
> GetIfPresent(K) (V, bool) // FIXME: Embedding the Cache interface
> Get(K) (V, error)
> }
>
> // See:
https://go2goplay.golang.org/p/T7h15CdUEa3
> // WIP:
https://github.com/goburrow/cache/tree/go2
code. It's particularly bad at embedding. In the real release it