light-core/pkg/myRedis/IntResult.go

34 lines
496 B
Go
Raw Normal View History

2024-12-17 22:28:48 +08:00
package myRedis
type IntResult struct {
Result int64
Err error
}
func NewIntResult(result int64, err error) *IntResult {
return &IntResult{Result: result, Err: err}
}
func (t *IntResult) Unwrap() int64 {
if t.Err != nil {
panic(t.Err)
}
return t.Result
}
func (t *IntResult) UnwrapOr(str int64) int64 {
if t.Err != nil {
return str
} else {
return t.Result
}
}
func (t *IntResult) UnwrapOrElse(f func() int64) int64 {
if t.Err != nil {
return f()
}
return t.Result
}