light-pkg/myRedis/InterfaceResult.go

26 lines
435 B
Go
Raw Permalink Normal View History

2024-12-18 03:41:30 +08:00
package myRedis
type InterfaceResult struct {
Result interface{}
Err error
}
func NewInterfaceResult(result interface{}, err error) *InterfaceResult {
return &InterfaceResult{Result: result, Err: err}
}
func (t *InterfaceResult) Unwrap() interface{} {
if t.Err != nil {
panic(t.Err)
}
return t.Result
}
func (t *InterfaceResult) UnwrapOr(a interface{}) interface{} {
if t.Err != nil {
return a
}
return t.Result
}