1 Star 0 Fork 0

h79 / gothird

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
result.go 1.05 KB
一键复制 编辑 原始数据 按行查看 历史
huqiuyun 提交于 2023-07-28 16:16 . 还是把 token 放在这里
package token
import "fmt"
const (
codeTryCount = -20000
)
var _ ResultObject = (*Result)(nil)
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 (r Result) GetCode() int32 {
return r.Code
}
func (r Result) GetSubCode() string {
return r.SubCode
}
func (r Result) GetMsg() string {
return r.Msg
}
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
}
1
https://gitee.com/h79/gothird.git
git@gitee.com:h79/gothird.git
h79
gothird
gothird
v1.8.103

搜索帮助