utilx

package
v0.0.0-...-678877b Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const TimeLayout = "2006-01-02 15:04:05"

Variables

This section is empty.

Functions

func AesDecryptECB

func AesDecryptECB(encrypted []byte, key []byte) (decrypted []byte)

AesDecryptECB AES-EBC

func AesEncryptECB

func AesEncryptECB(origData []byte, key []byte) (encrypted []byte)

AesEncryptECB AES-EBC

func ClientIP

func ClientIP(r *http.Request) string

ClientIP 获取客户端ip

func Copy

func Copy(toValue interface{}, fromValue interface{}) (err error)

Copy 复制结构体内容

func DirectClientIP

func DirectClientIP(r *http.Request) string

DirectClientIP 直接获取客户端ip

func DownloadFile

func DownloadFile(url string, filename string) error

DownloadFile 下载文件并保存到指定路径

func F2y

func F2y(amount int64) float64

F2y 分转元

func Fen2Y

func Fen2Y(amount int64) string

Fen2Y 分转元 返回 00.00 单位元

func Fen2Yuan

func Fen2Yuan(amount int64) string

Fen2Yuan 分转元

func GetDays

func GetDays(str string) int

func GetUserAgent

func GetUserAgent(req *http.Request) string

func GzipCompress

func GzipCompress(gzData string) (string, error)

GzipCompress 压缩gzip数据

func GzipUnCompress

func GzipUnCompress(gzData string) (string, error)

GzipUnCompress 解压gzip数据

func InSliceInt64

func InSliceInt64(val int64, s []int64) bool

InSliceInt64 判断slice中是否存在某元素,仅支持小切片

func InSliceStr

func InSliceStr(val string, s []string) bool

InSliceStr 判断slice中是否存在某元素,仅支持小切片

func IpIsInternal

func IpIsInternal(ip string) bool

IpIsInternal 检测IP地址是否为内网IP

func IsDev

func IsDev() bool

IsDev 是否开发环境

func IsExist

func IsExist(path string) bool

func IsMap

func IsMap(i interface{}) bool

func IsNumeric

func IsNumeric(str string) bool

func IsProd

func IsProd() bool

IsProd 是否生产环境

func MapToStruct

func MapToStruct(data map[string]interface{}, result interface{}) error

MapToStruct map[string]interface{} 转换为结构体

func MaskNameEnd

func MaskNameEnd(name string, appendLen int, appendStr string) string

MaskNameEnd 名称脱敏 保留最后一个字

func MaskNameFront

func MaskNameFront(name string) string

MaskNameFront 名称脱敏 保留最后一个字

func MaskPhone

func MaskPhone(phone string) string

MaskPhone 手机号脱敏

func MaskPhoneEndFront

func MaskPhoneEndFront(phone string, appendLen int, appendStr string) string

MaskPhoneEndFront 手机号脱敏-中件替换8个 *

func Md5

func Md5(input []byte) string

func MustInt64

func MustInt64(v interface{}, defaultval ...int64) int64

MustInt64 强制返回int64

func MustString

func MustString(v interface{}, defaultval ...string) string

MustString 类型转换-返回string

func NullTimeFormat

func NullTimeFormat(t sql.NullTime) string

NullTimeFormat 格式化sql.NullTime

func ParseTime

func ParseTime(str string) time.Time

ParseTime 文本转时间

func RandStr

func RandStr(length int) (string, error)

RandStr 生成指定长度的随机字符串

func Shuffle

func Shuffle[T any](slice []T)

Shuffle 打乱切片

func StructToMap

func StructToMap(data interface{}) map[string]interface{}

StructToMap 结构体转换为 map[string]interface{}

func TryInt64

func TryInt64(v interface{}) (int64, bool)

TryInt64 类型转换-int64

func TryParseTime

func TryParseTime(str string) (time.Time, error)

func TryString

func TryString(v interface{}) (string, bool)

TryString 类型转换-转换为string

func Xlsx

func Xlsx(data [][]interface{}, sheetName string) (*excelize.File, error)

func XlsxV2

func XlsxV2(data [][]interface{}, sheetName string) (*excelize.File, error)

XlsxV2 流式写入,节约内存

Types

type Empty

type Empty struct{}

Jump to

Keyboard shortcuts

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