package xy_sh import "fmt" // Error 自定义错误类型,包含返回码和错误信息 type Error struct { Code int `json:"code"` Message string `json:"msg"` } // Error 实现 error 接口 func (e *Error) Error() string { return fmt.Sprintf("code=%d, msg=%s", e.Code, e.Message) } // IsSuccess 判断业务返回码是否表示成功 func IsSuccess(code int) bool { return code == 0 }