common

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OK                 = 200  // Success
	NotLoggedIn        = 1000 // 未登录
	ParameterIllegal   = 1001 // 参数不合法
	UnauthorizedUserId = 1002 // 非法的用户Id
	Unauthorized       = 1003 // 未授权
	ServerError        = 1004 // 系统错误
	NotData            = 1005 // 没有数据
	ModelAddError      = 1006 // 添加错误
	ModelDeleteError   = 1007 // 删除错误
	ModelStoreError    = 1008 // 存储错误
	OperationFailure   = 1009 // 操作失败
	RoutingNotExist    = 1010 // 路由不存在
)

Variables

This section is empty.

Functions

func CheckCountryZone

func CheckCountryZone(country, zone string, en_country, en_zone, dis_country, dis_zone *[]string) bool

func CheckRecover

func CheckRecover()

* * @Description: 检测 recover并打印错误 stack * @Date: 2022-02-19 10:33:49 *

func GetErrorMessage

func GetErrorMessage(code uint32, message string) string

根据错误码 获取错误信息

func GetGID

func GetGID() uint64

* * @Description: 获取当前协程id * @return: uint64 * @Author: Iori * @Date: 2022-02-19 10:32:39 *

func GetLocalIP

func GetLocalIP() (ip string, err error)

* * @Description: 获取本地ip地址 * @return: ip * @return: err *

func GetOutboundIP

func GetOutboundIP() string

* * @Description: 获取外网ip地址 * @return: string * @Author: Iori *

func GetRandomByte

func GetRandomByte(n int) []byte

* * @Description: * @param: n * @return: string * @Author: Iori * @Date: 2022-06-01 16:41:37 *

func GetRandomStr

func GetRandomStr(n int) string

* * @Description: 随机指定长度字符串 * @param: n * @return: string * @Author: Iori * @Date: 2022-06-01 15:19:58 *

func IfOr

func IfOr[R any](flag bool, a, b R) R

* * @Description: 三目运算之泛型 * @param: flag * @param: a * @param: b * @return: R * @Author: Iori *

func IsNull

func IsNull(i interface{}) bool

* * @Description: 是否為null值 ,default * @param: i * @return: bool * @Author: Iori *

func MapToJson

func MapToJson(hashmap interface{}) string

* * @Description: * @param: hashmap * @return: string * @Author: Iori *

func RecoverTraceCode

func RecoverTraceCode()

* * @Description: 检测 recover并跟踪代码 * @Date: 2022-02-26 18:00:12 *

func StrVal

func StrVal(value interface{}) string

* * @Description: Strval 获取变量的字符串值,,浮点型 3.0将会转换成字符串3, "3",,非数值或字符类型的变量将会被转换成JSON格式字符串 * @param: value * @return: string *

func StructAssign

func StructAssign(binding interface{}, value interface{})

* * @Description: 结构体数据复制 * @param: binding 要修改的结构体 * @param: value 有数据的结构体 * @Author: Iori * @Date: 2022-02-19 10:32:57 *

func TraceCode

func TraceCode(code ...interface{})

* * @Description: 输出错误,跟踪代码 * @param: code * @Author: Iori * @Date: 2022-02-26 18:00:28 *

Types

type JsonResult

type JsonResult struct {
	Code uint32      `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

func Response

func Response(code uint32, message string, data interface{}) JsonResult

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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