1 Star 0 Fork 0

h79/gothird

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
result.go 878 Bytes
一键复制 编辑 原始数据 按行查看 历史
huqiuyun 提交于 3年前 . init
package result
import "fmt"
const (
codeTryCount = -20000
)
type Result struct {
Code int32
SubCode string
Msg string
Raw interface{}
}
// error.Error interface
func (r Result) Error() string {
return fmt.Sprintf("errcode: %v, subcode: %s, errmsg: %s, Raw: '%+v'", r.Code, r.SubCode, r.Msg, r.Raw)
}
func Error(code int32, err string) Result {
return Result{
Code: code,
Msg: err,
}
}
func SubError(code int32, subCode string, err string) Result {
return Result{
Code: code,
SubCode: subCode,
Msg: err,
}
}
func TryCount() Result {
return Result{
Code: codeTryCount,
Msg: "",
}
}
func Succeed() Result {
return Result{
Code: 0,
Msg: "",
}
}
func (r Result) Ok() bool {
return r.Code == 0
}
func (r Result) IsTokenError() bool {
return false
}
func (r Result) IsTryCount() bool {
return r.Code == codeTryCount
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/h79/gothird.git
git@gitee.com:h79/gothird.git
h79
gothird
gothird
v1.0.2

搜索帮助

371d5123 14472233 46e8bd33 14472233