xlib

package
v0.5.18 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HttpNotJsonHandler = func(str string) string {
	if !gjson.Valid(str) {
		return gjson.MustEncodeString(g.Map{"resp": str})
	}
	return str
}

HttpNotJsonHandler 处理 http 返回的不是个 json

Functions

func ErrorIsSystem added in v0.5.9

func ErrorIsSystem(err error) bool

ErrorIsSystem 是否为系统错误

func GetErrorCode added in v0.5.9

func GetErrorCode(err error) gcode.Code

GetErrorCode 获取 error 的 g code

func HttpClient

func HttpClient(method, url string, data any, opt ...any) (gJson *gjson.Json, err error)

HttpClient 发起一个http请求

func IF

func IF(condition bool, a, b any) any

func InArr

func InArr[T any](a T, arr []T) bool

InArr 是否在数组中

func Maintain

func Maintain(handler func())

Maintain 维持函数

func RedisScanData added in v0.5.18

func RedisScanData(ctx context.Context, key string, fn func(keys []string) (err error)) (err error)

RedisScanData 扫描 redis 数据 (替代 keys 操作)

func SafeExit

func SafeExit()

SafeExit 安全触发退出

func SelectAllToStruct

func SelectAllToStruct[T any](all gdb.Result) []T

SelectAllToStruct 查询多条转换为结构体组

func SelectOneToStruct

func SelectOneToStruct[T any](one gdb.Record) *T

SelectOneToStruct 查询单条转换为结构体

func Sha256

func Sha256(text string) string

Sha256 获取数据的 sha256

Types

This section is empty.

Jump to

Keyboard shortcuts

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