helper

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 13 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 GetLocalIP added in v0.1.0

func GetLocalIP() string

获取本机ip地址

func GetLocalIPs added in v0.1.0

func GetLocalIPs() (ips []string)

获取本机所有ip地址

func GetMacAddrs

func GetMacAddrs() (macAddrs []string)

获取本机mac地址

func GetStructFields added in v0.1.2

func GetStructFields(v any) (fields []string)

获取结构体字段

func JsonDecode

func JsonDecode(str string, v any) error

json字符串解码

func JsonEncode added in v0.1.8

func JsonEncode(v any) (string, 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