30 lines
511 B
Go
30 lines
511 B
Go
|
package myRedis
|
||
|
|
||
|
type SliceResult struct {
|
||
|
Result []interface{}
|
||
|
Err error
|
||
|
}
|
||
|
|
||
|
func NewSliceResult(result []interface{}, err error) *SliceResult {
|
||
|
return &SliceResult{Result: result, Err: err}
|
||
|
}
|
||
|
|
||
|
func (t *SliceResult) Unwrap() []interface{} {
|
||
|
if t.Err != nil {
|
||
|
panic(t.Err)
|
||
|
}
|
||
|
return t.Result
|
||
|
}
|
||
|
|
||
|
func (t *SliceResult) UnwrapOr(strs []interface{}) []interface{} {
|
||
|
if t.Err != nil {
|
||
|
return strs
|
||
|
} else {
|
||
|
return t.Result
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (t *SliceResult) Iter() *Iterator {
|
||
|
return NewIterator(t.Result)
|
||
|
}
|