Documentation
¶
Index ¶
- Constants
- Variables
- type ErrorModel
- type RespModel
- func FailureRespWithErrModel(obj *ErrorModel, args ...interface{}) RespModel
- func FailureRespWithErrModelObj(data interface{}, obj *ErrorModel) RespModel
- func FailureRespWithError(code int, e error) RespModel
- func FailureRespWithStr(code int, msg string, v ...interface{}) RespModel
- func NewRespModel(bytes []byte) RespModel
- func SuccessResp(data interface{}) RespModel
- type ResultModel
- func FailureResultWithErrModel[T any](obj *ErrorModel, args ...interface{}) ResultModel[T]
- func FailureResultWithErrModelObj[T any](data T, obj *ErrorModel) ResultModel[T]
- func FailureResultWithError[T any](code int, e error) ResultModel[T]
- func FailureResultWithStr[T any](code int, msg string, v ...interface{}) ResultModel[T]
- func NewResultModel[T any](bytes []byte) ResultModel[T]
- func SuccessResult[T any](data T) ResultModel[T]
- type RunStatus
Constants ¶
View Source
const ( FAILURE = 9999 SUCCESS = 0 )
View Source
const ( CLIENT = iota MASTER SLAVER ANALYSE )
View Source
const (
ErrorCodeConsoleWSClient = 1000 + iota
)
View Source
const Success = 0
Variables ¶
View Source
var ( Identify = "" Version = "" GitCommit = "" GitTag = "" BuildDate = "" )
View Source
var ErrorBaseNormal = func(info string) *ErrorModel { return NewErrModelByStr(global.ErrorCodeBase, "error : %v", info) }
View Source
var ErrorConsoleParamsFormat = func(msg string) *ErrorModel { return NewErrModelByStr(ErrorCodeConsoleWSClient, "the params is not right: [%v]", msg) }
Functions ¶
This section is empty.
Types ¶
type ErrorModel ¶
type ErrorModel struct {
Code int `json:"code"`
Message string `json:"message"`
Suggest interface{} `json:"suggest,omitempty"`
Params interface{} `json:"params,omitempty"`
}
func NewErrModel ¶
func NewErrModel(code int, err error) *ErrorModel
func NewErrModelByStr ¶
func NewErrModelByStr(code int, msg string, args ...interface{}) *ErrorModel
func (*ErrorModel) ToString ¶
func (eo *ErrorModel) ToString(args ...interface{}) string
type RespModel ¶
type RespModel struct {
Code int `json:"code" example:"0"`
Message string `json:"message,omitempty" example:""`
Header map[string]interface{} `json:"header,omitempty" example:""`
Data interface{} `json:"data,omitempty" example:""`
}
func FailureRespWithErrModel ¶
func FailureRespWithErrModel(obj *ErrorModel, args ...interface{}) RespModel
func FailureRespWithErrModelObj ¶
func FailureRespWithErrModelObj(data interface{}, obj *ErrorModel) RespModel
func FailureRespWithError ¶
func FailureRespWithStr ¶
func NewRespModel ¶
func SuccessResp ¶
func SuccessResp(data interface{}) RespModel
type ResultModel ¶
type ResultModel[T any] struct { Code int `json:"code" example:"0"` Message string `json:"message,omitempty" example:""` Header map[string]interface{} `json:"header,omitempty" example:""` Data T `json:"data,omitempty" example:""` }
func FailureResultWithErrModel ¶
func FailureResultWithErrModel[T any](obj *ErrorModel, args ...interface{}) ResultModel[T]
func FailureResultWithErrModelObj ¶
func FailureResultWithErrModelObj[T any](data T, obj *ErrorModel) ResultModel[T]
func FailureResultWithError ¶
func FailureResultWithError[T any](code int, e error) ResultModel[T]
func FailureResultWithStr ¶
func FailureResultWithStr[T any](code int, msg string, v ...interface{}) ResultModel[T]
func NewResultModel ¶
func NewResultModel[T any](bytes []byte) ResultModel[T]
func SuccessResult ¶
func SuccessResult[T any](data T) ResultModel[T]
func (ResultModel[T]) Bytes ¶
func (resp ResultModel[T]) Bytes() []byte
func (ResultModel[T]) IsSuccess ¶
func (resp ResultModel[T]) IsSuccess() bool
func (ResultModel[T]) String ¶
func (resp ResultModel[T]) String() string
Click to show internal directories.
Click to hide internal directories.