Add proper check for dst pointer
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
4af5b3af83
commit
1807721360
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue