xlib

package
v0.5.21 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: MIT Imports: 21 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 Base642File added in v0.5.20

func Base642File(base64Str, filePath, filename string) (err error)

Base642File Base64 转文件

func ErrorIsSystem added in v0.5.9

func ErrorIsSystem(err error) bool

ErrorIsSystem 是否为系统错误

func GetBase64Data added in v0.5.20

func GetBase64Data(base64Str string) (string, error)

GetBase64Data 获取 Base64 数据

func GetErrorCode added in v0.5.9

func GetErrorCode(err error) gcode.Code

GetErrorCode 获取 error 的 g code

func GetFileExtension added in v0.5.20

func GetFileExtension(base64Str string) (string, error)

GetFileExtension 获取文件后缀

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(ctx context.Context, conn gredis.Conn, keys []string) (err error), count int) (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