light-pkg/myRedis/SliceResult.go

30 lines
511 B
Go
Raw Permalink Normal View History

2024-12-18 03:41:30 +08:00
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)
}