response

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2024 License: MulanPSL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CodeMsgMap = map[int]string{}
	ShowMore   = true
)

Functions

func SetCode

func SetCode(v *int, code int)

func SetData

func SetData(v *interface{}, data interface{})

func SetErrCode

func SetErrCode(c *int, m *string, code int)

func SetError

func SetError(c *[]string, errs ...error)

func SetMeta

func SetMeta(v *interface{}, meta interface{})

func SetMsg

func SetMsg(v *string, msg string, msgArgs ...interface{})

Types

type Error

type Error interface {
	error
	Code() int
}

type ErrorDefault

type ErrorDefault struct {
	ErrMsg  string
	ErrCode int
}

func (*ErrorDefault) Code

func (v *ErrorDefault) Code() int

func (*ErrorDefault) Error

func (v *ErrorDefault) Error() string

type Response

type Response interface {
	SetErrCode(int) Response
	SetCustomError(Error) Response
	SetErrMsg(int, string, ...interface{}) Response
	SetData(interface{}) Response
	SetDataMsg(interface{}, string, ...interface{}) Response
	SetMeta(interface{}) Response
	AddError(...error) Response
}

func New

func New() Response

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL