diff --git a/README.md b/README.md index 1052792..03b34f3 100644 --- a/README.md +++ b/README.md @@ -541,6 +541,8 @@ import "github.com/duke-git/lancet/v2/fileutil" - **UnZip** : unzip the zip file and save it to dest path. [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil.md#UnZip)] [[play](https://go.dev/play/p/g0w34kS7B8m)] +- **CurrentPath** : return current absolute path. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil.md#CurrentPath)] ### 9. Formatter contains some functions for data formatting. @@ -553,6 +555,18 @@ import "github.com/duke-git/lancet/v2/formatter" - **Comma** : add comma to a number value by every 3 numbers from right, ahead by symbol char. [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter.md#Comma)] [[play](https://go.dev/play/p/eRD5k2vzUVX)] +- **Pretty** : pretty print data to JSON string. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter.md#Pretty)] +- **PrettyToWriter** : pretty encode data to writer. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter.md#PrettyToWriter)] +- **DecimalBytes** : returns a human readable byte size under decimal standard (base 1000). + [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter.md#DecimalBytes)] +- **BinaryBytes** : returns a human-readable byte size under binary standard (base 1024). + [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter.md#BinaryBytes)] +- **ParseDecimalBytes** : return the human readable bytes size string into the amount it represents(base 1000). + [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter.md#ParseDecimalBytes)] +- **ParseBinaryBytes** : return the human readable bytes size string into the amount it represents(base 1024). + [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter.md#ParseBinaryBytes)] ### 10. Function package can control the flow of function execution and support part of functional programming @@ -972,8 +986,12 @@ import "github.com/duke-git/lancet/v2/slice" - **Reverse** : return slice of element order is reversed to the given slice. [[doc](https://github.com/duke-git/lancet/blob/main/docs/slice.md#Reverse)] [[play](https://go.dev/play/p/8uI8f1lwNrQ)] -- **Reduce** : creates an slice of values by running each element of slice thru iteratee function. +- **Reducedeprecated** : creates an slice of values by running each element of slice thru iteratee function.(Deprecated: use ReduceBy) [[doc](https://github.com/duke-git/lancet/blob/main/docs/slice.md#Reduce)] +- **ReduceBy** : produces a value from slice by accumulating the result of each element as passed through the reducer function. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/slice.md#ReduceBy)] +- **ReduceRight** : ReduceRight is like ReduceBy, but it iterates over elements of slice from right to left. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/slice.md#ReduceRight)] [[play](https://go.dev/play/p/_RfXJJWIsIm)] - **Replace** : returns a copy of the slice with the first n non-overlapping instances of old replaced by new. [[doc](https://github.com/duke-git/lancet/blob/main/docs/slice.md#Replace)] @@ -1158,7 +1176,6 @@ import "github.com/duke-git/lancet/v2/strutil" [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#RemoveNonPrintable)] [[play](https://go.dev/play/p/og47F5x_jTZ)] - ### 19. System package contain some functions about os, runtime, shell command. ```go @@ -1248,9 +1265,13 @@ import "github.com/duke-git/lancet/v2/validator" - **IsEmptyString** : check if the string is empty. [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsEmptyString)] [[play](https://go.dev/play/p/dpzgUjFnBCX)] +- **IsFloat** : check if the value is float(float32, float34) or not. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsFloat)] - **IsFloatStr** : check if the string can convert to a float. - [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#LOYwS_Oyl7U)] + [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsFloatStr)] [[play](https://go.dev/play/p/LOYwS_Oyl7U)] +- **IsNumber** : check if the value is number(integer, float) or not. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsNumber)] - **IsNumberStr** : check if the string can convert to a number. [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsNumberStr)] [[play](https://go.dev/play/p/LzaKocSV79u)] @@ -1260,6 +1281,8 @@ import "github.com/duke-git/lancet/v2/validator" - **IsRegexMatch** : check if the string match the regexp. [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsRegexMatch)] [[play](https://go.dev/play/p/z_XeZo_litG)] +- **IsInt** : check if the string can convert to a number. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsInt)] - **IsIntStr** : check if the string can convert to a integer. [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsIntStr)] [[play](https://go.dev/play/p/jQRtFv-a0Rk)] @@ -1342,13 +1365,8 @@ import "github.com/duke-git/lancet/v2/xerror" [[doc](https://github.com/duke-git/lancet/blob/main/docs/xerror.md#TryUnwrap)] [[play](https://go.dev/play/p/acyZVkNZEeW)] - - ## How to Contribute - - - I really appreciate any code commits which make lancet lib powerful. Please follow the rules below to create your pull request. 1. Fork the repository. diff --git a/README_zh-CN.md b/README_zh-CN.md index 769d9a4..eaf5f1a 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -540,6 +540,8 @@ import "github.com/duke-git/lancet/v2/fileutil" - **UnZip** : zip 解压缩文件并保存在目录中。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil_zh-CN.md#UnZip)] [[play](https://go.dev/play/p/g0w34kS7B8m)] +- **CurrentPath** : 返回当前位置的绝对路径。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil_zh-CN.md#CurrentPath)] ### 9. formatter 格式化器包含一些数据格式化处理方法。 @@ -552,6 +554,18 @@ import "github.com/duke-git/lancet/v2/formatter" - **Comma** : 用逗号每隔 3 位分割数字/字符串,支持前缀添加符号。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter_zh-CN.md#Comma)] [[play](https://go.dev/play/p/eRD5k2vzUVX)] +- **Pretty** : 返回pretty JSON字符串。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter_zh-CN.md#Pretty)] +- **PrettyToWriter** : Pretty encode数据到writer。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter_zh-CN.md#PrettyToWriter)] +- **DecimalBytes** : 返回十进制标准(以1000为基数)下的可读字节单位字符串。precision参数指定小数点后的位数,默认为4。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter_zh-CN.md#DecimalBytes)] +- **BinaryBytes** : 返回binary标准(以1024为基数)下的可读字节单位字符串。precision参数指定小数点后的位数,默认为4。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter_zh-CN.md#BinaryBytes)] +- **ParseDecimalBytes** : 将字节单位字符串转换成其所表示的字节数(以1000为基数)。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter_zh-CN.md#ParseDecimalBytes)] +- **ParseBinaryBytes** : 将字节单位字符串转换成其所表示的字节数(以1024为基数)。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter_zh-CN.md#ParseBinaryBytes)] ### 10. function 函数包控制函数执行流程,包含部分函数式编程。 @@ -971,9 +985,13 @@ import "github.com/duke-git/lancet/v2/slice" - **Reverse** : 反转切片中的元素顺序。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/slice_zh-CN.md#Reverse)] [[play](https://go.dev/play/p/8uI8f1lwNrQ)] -- **Reduce** : 将切片中的元素依次运行 iteratee 函数,返回运行结果。 +- **Reducedeprecated** : 将切片中的元素依次运行iteratee函数,返回运行结果。(废弃:建议使用ReduceBy) [[doc](https://github.com/duke-git/lancet/blob/main/docs/slice_zh-CN.md#Reduce)] [[play](https://go.dev/play/p/_RfXJJWIsIm)] +- **ReduceBy** : 对切片元素执行reduce操作。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/slice_zh-CN.md#ReduceBy)] +- **ReduceRight** : 类似ReduceBy操作,迭代切片元素顺序从右至左。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/slice_zh-CN.md#ReduceRight)] - **Replace** : 返回切片的副本,其中前 n 个不重叠的 old 替换为 new。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/slice_zh-CN.md#Replace)] [[play](https://go.dev/play/p/P5mZp7IhOFo)] @@ -1249,9 +1267,13 @@ import "github.com/duke-git/lancet/v2/validator" - **IsEmptyString** : 验证字符串是否是空字符串。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsEmptyString)] [[play](https://go.dev/play/p/dpzgUjFnBCX)] +- **IsFloat** : 验证参数是否是浮点数((float32,float34)。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsFloat)] - **IsFloatStr** : 验证字符串是否是可以转换为浮点数。 - [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#LOYwS_Oyl7U)] + [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsFloatStr)] [[play](https://go.dev/play/p/LOYwS_Oyl7U)] +- **IsNumber** : 验证参数是否是数字(integer,float)。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsNumber)] - **IsNumberStr** : 验证字符串是否是可以转换为数字。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsNumberStr)] [[play](https://go.dev/play/p/LzaKocSV79u)] @@ -1261,13 +1283,15 @@ import "github.com/duke-git/lancet/v2/validator" - **IsRegexMatch** : 验证字符串是否可以匹配正则表达式。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsRegexMatch)] [[play](https://go.dev/play/p/z_XeZo_litG)] +- **IsInt** : 验证参数是否是整数(int, unit)。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsInt)] - **IsIntStr** : 验证字符串是否是可以转换为整数。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsIntStr)] [[play](https://go.dev/play/p/jQRtFv-a0Rk)] -- **IsIp** : 验证字符串是否是 ip 地址。 +- **IsIp** : 验证字符串是否是ip地址。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsIp)] [[play](https://go.dev/play/p/FgcplDvmxoD)] -- **IsIpV4** : 验证字符串是否是 ipv4 地址。 +- **IsIpV4** : 验证字符串是否是ipv4地址。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsIpV4)] [[play](https://go.dev/play/p/zBGT99EjaIu)] - **IsIpV6** : 验证字符串是否是 ipv6 地址。 diff --git a/docs/slice.md b/docs/slice.md index b3e0f3c..7414bbb 100644 --- a/docs/slice.md +++ b/docs/slice.md @@ -62,7 +62,7 @@ import ( - [FlatMap](#FlatMap) - [Merge](#Merge) - [Reverse](#Reverse) -- [Reduce](#Reduce) +- [Reducedeprecated](#Reduce) - [ReduceBy](#ReduceBy) - [ReduceRight](#ReduceRight) - [Replace](#Replace) @@ -1474,7 +1474,7 @@ func main() { ### Reduce -
Reduce slice.
+Reduce slice.(Deprecated: use ReduceBy)
Signature: diff --git a/docs/slice_zh-CN.md b/docs/slice_zh-CN.md index 0d98644..63b1a3b 100644 --- a/docs/slice_zh-CN.md +++ b/docs/slice_zh-CN.md @@ -62,7 +62,7 @@ import ( - [FlatMap](#FlatMap) - [Merge](#Merge) - [Reverse](#Reverse) -- [Reduce](#Reduce) +- [Reducedeprecated](#Reduce) - [ReduceBy](#ReduceBy) - [ReduceRight](#ReduceRight) - [Replace](#Replace) @@ -1475,7 +1475,7 @@ func main() { ### Reduce -将切片中的元素依次运行iteratee函数,返回运行结果
+将切片中的元素依次运行iteratee函数,返回运行结果(废弃:建议使用ReduceBy)
函数签名: @@ -1509,7 +1509,7 @@ func main() { ### ReduceBy -对切片中执行reduce操作。
+对切片元素执行reduce操作。
函数签名: diff --git a/docs/validator.md b/docs/validator.md index 112d2e2..98aeb5b 100644 --- a/docs/validator.md +++ b/docs/validator.md @@ -629,7 +629,7 @@ func main() { } ``` -### IsInt +### IsFloatCheck if the value is float(float32, float34) or not.
diff --git a/docs/validator_zh-CN.md b/docs/validator_zh-CN.md index d59cf47..7280311 100644 --- a/docs/validator_zh-CN.md +++ b/docs/validator_zh-CN.md @@ -629,7 +629,7 @@ func main() { } ``` -### IsInt +### IsFloat验证参数是否是浮点数((float32, float34)。