Documentation ¶
Index ¶
- Constants
- func ArrayChunk[T any](arrayData []T, length int) [][]T
- func ArrayDiff[T comparable](base []T, othersParams ...[]T) []T
- func ArrayInt2ArrayString(in []int) []string
- func ArrayIntersect[T comparable](base []T, othersParams ...[]T) []T
- func ArrayMerge[T any](datas ...[]T) []T
- func ArrayProduct[T constraints.Float | constraints.Integer](data []T) T
- func ArrayReverse[T any](array []T)
- func ArraySearch[T comparable](item T, arrayData []T) int
- func ArraySum[T constraints.Float | constraints.Integer](data []T) T
- func ArrayUnique[T comparable](arrayData []T) []T
- func ArrayWalk[T any](data []T, callback func(item T, index int) bool)
- func Basename(filename string, suffix ...string) string
- func Bin2Hex(binData []byte) string
- func ChDir(dir string) bool
- func ChMod(filename string, mode os.FileMode) bool
- func Chown(filename, username string) bool
- func Copy(src, dest string) bool
- func Date(format string, timestamp ...int64) string
- func Dirname(path string) string
- func Explode(separator, str string) []string
- func FileATime(filename string) (sys interface{})
- func FileExists(filename string) bool
- func FileGetContents(filename string) []byte
- func FileMTime(filename string) int64
- func FilePutContents(filename string, content []byte, fileMode os.FileMode) (int, error)
- func FileSize(filename string) int64
- func GetCWD() string
- func GetSystemOS() string
- func Hex2Bin(s string) ([]byte, error)
- func If[T any](isTrue bool, a, b T) T
- func Implode(separator string, data []string) string
- func InArray[T comparable](item T, arrayData []T) bool
- func IsDir(filename string) bool
- func IsFile(filename string) bool
- func IsReadable(filename string) bool
- func IsWritable(filename string) bool
- func Join[T constraints.Float | constraints.Integer | ~string](a []T, sep string) string
- func LCFirst(s string) string
- func LTrim(str, deleteStr string) string
- func MD5(data []byte) string
- func MkDir(pathname string, fileMode os.FileMode, recursive bool) bool
- func ParseDate(dateStr string, layouts ...string) (time.Time, error)
- func PregMatch(pattern, s string) ([]string, error)
- func PregMatchAll(pattern, s string) ([][]string, error)
- func PregReplace(pattern, repl, src string) (string, error)
- func PregSplit(pattern, src string) ([]string, error)
- func RTrim(str, deleteStr string) string
- func ReadDir(dir string) ([]os.DirEntry, error)
- func Rename(src, dest string) error
- func Sha1(data []byte) string
- func StrCMP(s1, s2 string) int
- func StrContains(str, subStr string) bool
- func StrEndsWith(s, suffixStr string) bool
- func StrIPos(s, subStr string) int
- func StrIReplace(searchStr, replaceStr, findInStr string) (string, error)
- func StrLen(s string) int
- func StrPad(str string, padLen int, padStr string, padType int) string
- func StrPos(s, subStr string) int
- func StrRIPos(s, subStr string) int
- func StrRPos(s, subStr string) int
- func StrRepeat(s string, count int) string
- func StrReplace(search, repl, replaceIn string) string
- func StrRev(s string) string
- func StrShuffle(s string) string
- func StrSplit(s string, splitLen int) []string
- func StrStartWith(s, prefix string) bool
- func StrStr(s, substr string, needBefore bool) string
- func StrToLower(s string) string
- func StrToTime(format string, relativeTimestamp ...int64) (time.Time, error)
- func StrToUpper(s string) string
- func StripTags(src string) string
- func SubStr(s string, start, length int) string
- func SubStrRune(s string, start, length int) string
- func Time() int64
- func ToTimestamp(dateStr string, layouts ...string) int64
- func Trim(str string) string
- func UCFirst(s string) string
- func UCWords(s string) string
- func UnLink(filename string) bool
Constants ¶
const ( DefaultDateTimeFormatTpl = "2006-01-02 15:04:05" DefaultDateFormatTpl = "2006-01-02" DefaultTimeFormatTpl = "15:04:05" )
const ( StrPadLeft = iota StrPadRight StrPadBoth )
Variables ¶
This section is empty.
Functions ¶
func ArrayChunk ¶ added in v1.0.7
ArrayChunk 整数版本的数组切割。将arrayData按照每个长度为length切割为子数组
func ArrayDiff ¶
func ArrayDiff[T comparable](base []T, othersParams ...[]T) []T
ArrayDiff 模拟PHP array_diff函数 计算差集
func ArrayInt2ArrayString ¶
ArrayInt2ArrayString 将int slice转为string slice
func ArrayIntersect ¶
func ArrayIntersect[T comparable](base []T, othersParams ...[]T) []T
ArrayIntersect 模拟PHP array_intersect函数 计算交集
func ArrayProduct ¶
func ArrayProduct[T constraints.Float | constraints.Integer](data []T) T
ArrayProduct 计算数组的各元素的乘积
func ArrayReverse ¶ added in v1.0.5
func ArrayReverse[T any](array []T)
ArrayReverse 数组反转,需要传指针进来,仅支持slice,array请转为slice
func ArraySearch ¶
func ArraySearch[T comparable](item T, arrayData []T) int
ArraySearch 搜索arrayData里面是否有item,有返回对应的index,无返回-1,只返回首次
func ArraySum ¶
func ArraySum[T constraints.Float | constraints.Integer](data []T) T
ArraySum 计算数组之和
func ArrayUnique ¶
func ArrayUnique[T comparable](arrayData []T) []T
ArrayUnique 切片去重,目前仅支持int和string两种类型
func Date ¶
Date PHP的date函数 timestamp 时间戳,传了时间戳则以此为准,不传默认当前时间 用法参考PHP函数:https://www.php.net/manual/zh/function.date.php 但是不是每一个标志都实现了,具体可以参考下面的map对照表
func FileATime ¶
func FileATime(filename string) (sys interface{})
FileATime 获取文件上次访问时间 对应windows下使用: fileSys := sys.(*syscall.Win32FileAttributeData) second := fileSys.LastAccessTime.Nanoseconds() / 1e9 对于linux下使用 fileSys := sys.(*syscall.Stat_t) second := fileSys.Atim.Sec
func FilePutContents ¶
FilePutContents 写入文件内容
func Join ¶
func Join[T constraints.Float | constraints.Integer | ~string](a []T, sep string) string
Join 将一个int slice转为sep分割的字符串
func PregMatchAll ¶
PregMatchAll 使用正则匹配字符串s中所有匹配的数据
func StrIReplace ¶
StrIReplace 大小写忽略的字符串替换
func StrToTime ¶
StrToTime 模拟PHP的strtotime函数 支持format有:"+1 year"、"-1 year"、"+5 months"、"1 year +5 month -1 day +10 hours -23 minutes +5 seconds"等 relativeTimestamp是时间戳,单位秒,之所以设为可变参数,是为了和php一致,使用时可以省略,省略则默认当前时间 relativeTimestamp传多个值没用,只用到relativeTimestamp[0]
func SubStrRune ¶
SubStrRune 字符串截取,需要注意是否越界,这是按照字符截取的
func ToTimestamp ¶
ToTimestamp 将一个日期/时间转为时间戳,出错则返回-1 layouts省略则采用默认2006-01-02 15:04:05
Types ¶
This section is empty.