1 Star 0 Fork 0

masaichi/工具包

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
StringResult.go 602 Bytes
Copy Edit Raw Blame History
邓正锋 authored 2024-05-17 16:02 +08:00 . 添加redis操作方法
package goredis
type StringResult struct {
Result string
Err error
}
func NewStringResult(result string, err error) *StringResult {
return &StringResult{Result: result, Err: err}
}
func (this *StringResult) Unwrap() string {
if this.Err != nil {
panic(this.Err)
}
return this.Result
}
func (this *StringResult) UnwrapDefault(def string) string {
if this.Err != nil {
return def
}
return this.Result
}
// 如果获取不到缓存,则执行默认方法
func (this *StringResult) UnwrapElse(f func() string) interface{} {
if this.Err != nil {
return f()
}
return this.Result
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/masaichi/mastool.git
git@gitee.com:masaichi/mastool.git
masaichi
mastool
工具包
v0.0.4

Search