lcutils

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolDiff

func BoolDiff[T comparable](list1, list2 []T) []T

BoolDiff list1-list2 布尔-差集, 有去重逻辑 移除list1 中 所有的 list2 元素

func BoolEq

func BoolEq[T comparable](list1, list2 []T) bool

BoolEq 布尔-相等 有去重逻辑

func BoolIntersection

func BoolIntersection[T comparable](list1, list2 []T) []T

BoolIntersection list1,list2相同的元素 布尔-交集, 有去重逻辑 list1 和 list2 元素,交集

func BoolUnion

func BoolUnion[T comparable](list1, list2 []T) []T

BoolUnion list1+list2 布尔-并, 有去重逻辑 list1 和 list2 元素,并集

func CheckLandline

func CheckLandline(phoneNumber string) bool

func CheckPhone

func CheckPhone(phoneNumber string) bool

func CheckPhoneAll

func CheckPhoneAll(phoneNumber string) bool

func CleanString added in v1.2.0

func CleanString(s string) string

CleanString 将字符串中的空格、空字符和不可见字符替换为下划线

func CopyFile

func CopyFile(src, dst string) error

func CopyTemplateToTempFile

func CopyTemplateToTempFile(templatePath string) (tmpFile *os.File, err error)

CopyTemplateToTempFile 复制模板文件到临时文件,返回临时文件路径

func CopyTemplateToTempFileName

func CopyTemplateToTempFileName(templatePath string) (string, error)

CopyTemplateToTempFileName 复制模板文件到临时文件,返回临时文件路径

func FirstStrRight

func FirstStrRight(str string, key string) string

第一个key右边第一个子串

func GenerateOrderID32

func GenerateOrderID32() string

GenerateOrderID32 格式 yyyymmddHHMMSS + 18位随机数,有字母

func GenerateOrderID32Number

func GenerateOrderID32Number() string

GenerateOrderID32Number 格式 yyyymmddHHMMSS + 18位随机数, 纯数字

func GetFileName

func GetFileName(path string) string

func GetFileNameNoSuffix

func GetFileNameNoSuffix(path string) string

func GetFileSuffix

func GetFileSuffix(path string) string

获取文件后缀,不带点

func HasText

func HasText(s string) bool

func HasTextP

func HasTextP(s *string) bool

func LastStrRight

func LastStrRight(str string, key string) string

最后一个key右边第一个子串

func Like

func Like(key string, list []string) string

Like 模糊匹配,返回最匹配的

func ListHas

func ListHas[T comparable](slice []T, item T) bool

集合中是否包含item

func LogJson

func LogJson(v any)

func MatchProvinceCity

func MatchProvinceCity(address string, provinces []string, cityToProvince map[string]string) string

MatchProvinceCity 返回地址中最匹配的标准省市名称 provinces: 所有标准省名称列表 cityToProvince: 市名称到省名称的映射(例如 "深圳" -> "广东省")

func NewTempDirName

func NewTempDirName() (string, error)

生成唯一临时目录名(返回目录路径和错误)

func NewTempDirNameMust

func NewTempDirNameMust() string

生成唯一临时目录名(必须成功,失败时 panic)

func NewTempFile

func NewTempFile(suffix string) (*os.File, error)

生成唯一临时文件(返回文件对象和错误)

func NewTempFileMust

func NewTempFileMust(suffix string) *os.File

强制生成临时文件(失败时panic)

func NewTempFileName

func NewTempFileName(suffix string) (string, error)

生成唯一临时文件名(返回路径和错误)

func NewTempFileNameMust

func NewTempFileNameMust(suffix string) string

强制生成临时文件名(失败时panic)

func NilToZero

func NilToZero[T any](t *T) T

nil 返回 零值

func NilToZeroP

func NilToZeroP[T any](t *T) *T

指针为nil时,返回零值指针

func Num2Str

func Num2Str[T constraints.Integer](num T) string

Num2Str 将任意整数类型的数值转换为字符串

func RemoveDuplicates

func RemoveDuplicates[T comparable](slice []T) []T

去重函数,适用于任何可比较的类型

func SanitizeFileName4URL

func SanitizeFileName4URL(url string, size ...int) string

func Str2Num

func Str2Num(str string) (int64, error)

Str2Num 将字符串转换为int64数值,支持任意进制解析

func Str2NumMust

func Str2NumMust(str string) int64

func StrContainsAll

func StrContainsAll(str string, list ...string) bool

func StrContainsAny

func StrContainsAny(str string, list ...string) bool

Types

type ListToolBuilder

type ListToolBuilder struct {
	// contains filtered or unexported fields
}

func ListTool

func ListTool(list ...any) *ListToolBuilder

func (*ListToolBuilder) Check

func (t *ListToolBuilder) Check() bool

func (*ListToolBuilder) HasAll

func (t *ListToolBuilder) HasAll(list ...any) *ListToolBuilder

func (*ListToolBuilder) HasAny

func (t *ListToolBuilder) HasAny(list ...any) *ListToolBuilder

func (*ListToolBuilder) NotAll

func (t *ListToolBuilder) NotAll(list ...any) *ListToolBuilder

Jump to

Keyboard shortcuts

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