helper

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppName

func AppName() string

func ClientAddr

func ClientAddr(ctx *fasthttp.RequestCtx) string

获取客户端地址(ip+port)

func ClientIP

func ClientIP(ctx *fasthttp.RequestCtx) (string, int)

获取客户端ip

func Error

func Error(errCode int, msg string, data any) (res *types.Result)

响应错误数据

func ErrorResponse

func ErrorResponse(ctx *fasthttp.RequestCtx, errCode int, msg string, data any)

响应错误数据

func GetEnvDefault

func GetEnvDefault(key, defVal string) string

取环境变量

func GetIPs

func GetIPs() (ips []string)

获取本机ip地址

func GetMacAddrs

func GetMacAddrs() (macAddrs []string)

获取本机mac地址

func JsonDecode

func JsonDecode(str string, v any) error

json字符串解码

func MD5

func MD5(v string) string

字符串md5

func MapToStruc

func MapToStruc[_type interface {
	int | string
}](m map[_type]any, s any) (err error)

map转struc

func RangeRand

func RangeRand(min, max int) int

取随机数

func RunFuncName

func RunFuncName() string

当前运行时方法名

func RunPackageName

func RunPackageName() string

当前运行时包名

func SnakeString

func SnakeString(s string) string

转为蛇形字符串

func Success

func Success(msg string, data any) (res *types.Result)

响应成功数据

func Time

func Time() string

获取当前日期时间

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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