Documentation ¶
Index ¶
- func CompareStringSlice(str1, str2 []string) bool
- func CompareStringSlicePrefix(str, substr []string) bool
- func FillSlice[T any](slice []T, length int, fill T) []T
- func FindIndex[T comparable](arr []T, target T) int
- func GetExecutablePath() string
- func RandomStr(length int) string
- func RandomStrWithSource(length int, source string) string
- func Reverse[T any](arr []T) []T
- func UUID() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareStringSlicePrefix ¶
CompareStringSlicePrefix 比较两个 []string,判断 str 中每一项是否包含 substr 中的每一项
func FindIndex ¶
func FindIndex[T comparable](arr []T, target T) int
FindIndex 返回元素在 slice 中所在的位置
如果未命中,-1
func GetExecutablePath ¶
func GetExecutablePath() string
GetExecutablePath 获取执行文件路径,在 main 包下面调用,能获取到准确地路径
通过判断是否在临时目录,区分 go run 和 go build go run: runtime.Caller(1) 获取调用者的文件路径 go build: os.Executable() 获取文件路径
func RandomStr ¶
RandomStr 随机字符串,包含大小写字母、数字、一般字符
字符集:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890~!@#$%^&*-+
func RandomStrWithSource ¶
RandomStrWithSource 随机字符串,自行提供字符集
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.