utils

package
v0.0.0-...-5693655 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDeCrypt

func AesDeCrypt(content []byte) ([]byte, error)

AesDeCrypt @Description: AES解密

func AesEnCrypt

func AesEnCrypt(plainBytes []byte) []byte

AesEnCrypt @Description: AES加密

func FileHash

func FileHash(filePath string, h hash.Hash) (string, error)

FileHash @Description: 计算文件哈希

func FilterSymbol

func FilterSymbol(src string) string

FilterSymbol @Description: 过滤特殊字符

func GeneratePrivateIp

func GeneratePrivateIp(input string) string

GeneratePrivateIp @Description: 通过字符串生成固定内网IP

func InArrayInt64

func InArrayInt64(src int64, target []int64) bool

InArrayInt64 @Description: 判断int64是否在数组内

func InArrayString

func InArrayString(src string, target []string) bool

InArrayString @Description: 判断字符串是否在数组内

func InArrayUint64

func InArrayUint64(src uint64, target []uint64) bool

InArrayUint64 @Description: 判断uint64是否在数组内

func IsEmpty

func IsEmpty(val any) bool

IsEmpty @Description: 判断any类型数据是否为空

func IsPrivateIp

func IsPrivateIp(ipString string) bool

IsPrivateIp @Description: 判断是否为私有IP

func Md5EnCrypt

func Md5EnCrypt(data string) string

Md5EnCrypt @Description: MD5加密

func PKCS7Padding

func PKCS7Padding(data []byte, blockSize int) []byte

PKCS7Padding @Description: 添加PKCS7填充

func Random

func Random(l int, t int) string

Random @Description: 随机生成字符串

func RandomImei

func RandomImei(prefix string) string

RandomImei @Description: 随机生成IMEI

func RandomMeid

func RandomMeid(prefix string) string

RandomMeid @Description: 随机生成MEID

func TernaryIf

func TernaryIf[T any](condition bool, trueValue, falseValue T) T

TernaryIf @Description: 三元表达式

func TernaryIfFunc

func TernaryIfFunc[T any](condition bool, trueValue, falseValue func() T) T

TernaryIfFunc @Description: 三元表达式-返回方法

Types

type LocalTime

type LocalTime time.Time

LocalTime 自定义时间类型

func NewLocalTime

func NewLocalTime(t time.Time) LocalTime

NewLocalTime 构造方法

func NowTime

func NowTime() LocalTime

NowTime 当前时间

func (LocalTime) IsZero

func (t LocalTime) IsZero() bool

IsZero 判断是否为0值

func (LocalTime) MarshalJSON

func (t LocalTime) MarshalJSON() ([]byte, error)

MarshalJSON 实现 json.Marshaler 接口

func (LocalTime) MarshalText

func (t LocalTime) MarshalText() ([]byte, error)

MarshalText 文本序列化接口支持(用于 csv、form、query)

func (*LocalTime) Scan

func (t *LocalTime) Scan(value interface{}) error

Scan 实现 sql.Scanner 接口,用于从数据库读取数据

func (LocalTime) String

func (t LocalTime) String() string

String 格式化时间

func (LocalTime) Time

func (t LocalTime) Time() time.Time

Time 转换成 GO time.Time

func (*LocalTime) UnmarshalJSON

func (t *LocalTime) UnmarshalJSON(data []byte) error

UnmarshalJSON 实现 json.Unmarshaler 接口

func (*LocalTime) UnmarshalText

func (t *LocalTime) UnmarshalText(data []byte) error

UnmarshalText 文本序列化接口支持(用于 csv、form、query)

func (LocalTime) Value

func (t LocalTime) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口,用于将数据存入数据库

Jump to

Keyboard shortcuts

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