tool

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2025 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTime

func AddTime(unit string, quantity int64, baseTime ...time.Time) time.Time

func CloneMapToStruct

func CloneMapToStruct(input any, output interface{}) error

func Contains

func Contains[T comparable](slice []T, target T) bool

func ConvertValueToString

func ConvertValueToString(value reflect.Value) string

ConvertValueToString converts the value to string

func Curve25519Genkey

func Curve25519Genkey(StdEncoding bool, inputBase64 string) (public, private string, err error)

func DayDiff

func DayDiff(startTime, endTime time.Time) int64

func DaysToMonthDay

func DaysToMonthDay(t time.Time, targetDay int) int64

func DaysToNextMonth

func DaysToNextMonth(t time.Time) int64

func DaysToYearDay

func DaysToYearDay(t time.Time, month int, day int) int64

func DeepCopy

func DeepCopy[T, K any](destStruct T, srcStruct K, opts ...CopyOption) T

func EncodePassWord

func EncodePassWord(str string) string

func ExtractVersionNumber

func ExtractVersionNumber(versionStr string) int

func FormatFloat

func FormatFloat(num float64, decimal int) string

func FormatStringToFloat

func FormatStringToFloat(str string) float64

func GenerateCipher

func GenerateCipher(serverKey string, length int) string

GenerateCipher 根据公钥生成固定长度密文

func GenerateETag

func GenerateETag(data []byte) string

func GenerateShortID

func GenerateShortID(privateKey string) string

func GenerateTradeNo

func GenerateTradeNo() string

func GetLastDayOfMonth

func GetLastDayOfMonth(t time.Time) int64

GetLastDayOfMonth 获取指定时间所在月份的最后一天

func GetYearDays

func GetYearDays(t time.Time, month int, day int) int64

func Int64SliceToString

func Int64SliceToString(intSlice []int64) string

func Int64SliceToStringSlice

func Int64SliceToStringSlice(slice []int64) []string

func Int64ToStringSlice

func Int64ToStringSlice(intSlice []int64) []string

func IsValidImageSize

func IsValidImageSize(base64Str string, maxSizeKB int64) bool

IsValidImageSize 检查base64图片是否有效且未超出大小限制 base64Str: base64编码的图片字符串 maxSizeKB: 最大允许大小(KB),int64类型 返回: bool - true表示图片有效且未超限,false表示无效或超限

func MaskEmail

func MaskEmail(email string) string

func Md5Encode

func Md5Encode(str string, isUpper bool) string

func MicrosecondsStr

func MicrosecondsStr(elapsed time.Duration) string

func MonthDiff

func MonthDiff(startTime, endTime time.Time) int

func ParseRedisURI

func ParseRedisURI(uri string) (addr, password string, database int, err error)

func RedisPing

func RedisPing(addr, password string, database int) error

func RemoveDuplicateElements

func RemoveDuplicateElements[T comparable](input ...T) []T

func RemoveElementBySlice

func RemoveElementBySlice[T comparable](slice []T, element T) []T

func RemoveStringElement added in v1.0.1

func RemoveStringElement(arr []string, element ...string) []string

RemoveStringElement 移除指定元素

func RenderTemplateToString

func RenderTemplateToString(tmpl string, data interface{}) (string, error)

func ShallowCopy

func ShallowCopy[T, K interface{}](destStruct T, srcStruct K, opts ...CopyOption) T

func SliceDifferenceInt64

func SliceDifferenceInt64(slice1, slice2 []int64) []int64

SliceDifferenceInt64 returns the difference of two slices

func SliceIntersectInt64

func SliceIntersectInt64(slice1, slice2 []int64) []int64

func SliceIsExistInt64

func SliceIsExistInt64(slice []int64, value int64) bool

SliceIsExistInt64 checks if a value exists in a slice

func StringMergeAndRemoveDuplicates

func StringMergeAndRemoveDuplicates(strs ...string) []string

StringMergeAndRemoveDuplicates Tool function to convert multiple comma separated strings into [] strings and deduplicate them

func StringSliceContains

func StringSliceContains(slice []string, str string) bool

func StringSliceToInt64Slice

func StringSliceToInt64Slice(slice []string) []int64

func StringSliceToString

func StringSliceToString(stringSlice []string) string

string slice to string

func StringToInt64Slice

func StringToInt64Slice(s string) []int64

func SystemConfigSliceReflectToStruct

func SystemConfigSliceReflectToStruct(slice []*system.System, structType any)

func Tern

func Tern[T any](cond bool, a, b T) T

Tern 三目运算

func VerifyPassWord

func VerifyPassWord(passwd, EncodePasswd string) bool

func YearDiff

func YearDiff(startTime, endTime time.Time) int

Types

type CopyOption added in v1.0.1

type CopyOption func(*copier.Option)

CopyOption 定义复制选项的函数类型

func CopyWithIgnoreEmpty added in v1.0.1

func CopyWithIgnoreEmpty(ignoreEmpty bool) CopyOption

CopyWithIgnoreEmpty 设置是否忽略空值

Jump to

Keyboard shortcuts

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