Add proper check for dst pointer
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Tyler 2019-10-02 20:38:20 -04:00
parent 4af5b3af83
commit 1807721360
1 changed files with 7 additions and 2 deletions

View File

@ -8,7 +8,8 @@ import (
)
var (
MemoryCacheNotExists = errors.New("item does not exist")
ErrMemoryCacheNotExists = errors.New("item does not exist")
ErrMemoryCacheNotSupported = errors.New("memory cache does not support retrieving items without a destination pointer")
)
type MemoryCache struct {
@ -31,7 +32,11 @@ func (mc *MemoryCache) Get(key string, dst ...interface{}) ([]byte, error) {
item, exists := mc.c.Get(key)
if !exists {
return nil, MemoryCacheNotExists
return nil, ErrMemoryCacheNotExists
}
if len(dst) == 0 {
return nil, ErrMemoryCacheNotSupported
}
v := dst[0]