Add proper check for dst pointer
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Tyler 2019-10-02 20:38:20 -04:00
parent 4af5b3af83
commit 1807721360

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]