helper

package
v0.3.46 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RangeLetter0 = "0"
	RangeLetter1 = "1"
)

Variables

This section is empty.

Functions

func AnyToBytes added in v0.3.3

func AnyToBytes(data any) (*[]byte, error)

any转bytes

func AppName

func AppName() string

func ClientAddr

func ClientAddr(ctx *fasthttp.RequestCtx) string

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

func ClientIP

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

获取客户端ip

func CurrentFile added in v0.1.13

func CurrentFile() string

获取当前文件名

func Error

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

响应错误数据

func ErrorResponse

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

响应错误数据

func GetEnvDefault

func GetEnvDefault(key, defVal string) string

取环境变量

func GetFileVariateNameAll added in v0.1.13

func GetFileVariateNameAll(FilePath string) (names []string)

获取文件内的所有变量名

func GetLocalIP added in v0.1.0

func GetLocalIP(address ...string) string

获取本机ip地址,默认获取对外的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 IpType added in v0.3.7

func IpType(ip string) uint8

判断ip类型

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 RandString added in v0.3.14

func RandString(n int, bytes ...string) string

获取指定长度的随机字符串,可自定义字符串

func RangeRand

func RangeRand(min, max int) int

取随机数

func RpcRequestData added in v0.1.17

func RpcRequestData() (rpcRequestData rpc.RpcRequestData)

获取rpc上下文请求数据

func RunFuncName

func RunFuncName() string

当前运行时方法名

func RunPackageName

func RunPackageName() string

当前运行时包名

func SetRpcRequestData added in v0.3.45

func SetRpcRequestData(rpcRequestData rpc.RpcRequestData)

设置rpc上下文请求数据

func SnakeString

func SnakeString(s string) string

转为蛇形字符串

func Success

func Success(msg string, datas ...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