18 lines
333 B
Go
18 lines
333 B
Go
package cache
|
|
|
|
type InterfaceResult struct {
|
|
Result interface{}
|
|
Err error
|
|
}
|
|
|
|
func NewInterfaceResult(result interface{}, err error) *InterfaceResult {
|
|
return &InterfaceResult{Result: result, Err: err}
|
|
}
|
|
|
|
func (ths *InterfaceResult) Unwrap_Or(v interface{}) interface{} {
|
|
if ths.Err != nil {
|
|
return v
|
|
}
|
|
return ths.Result
|
|
}
|