diff --git a/README.md b/README.md index 1c16b7c..987724c 100644 --- a/README.md +++ b/README.md @@ -200,7 +200,7 @@ import "github.com/duke-git/lancet/v2/condition" [[play](https://go.dev/play/p/W1SSUmt6pvr)] - **Or** : returns false if neither a nor b is truthy. [[doc](https://github.com/duke-git/lancet/blob/main/docs/condition.md#Or)] -[[play](https://go.dev/play/p/UlQTxHaeEkq)] + [[play](https://go.dev/play/p/UlQTxHaeEkq)] - **Xor** : returns true if a or b but not both is truthy. [[doc](https://github.com/duke-git/lancet/blob/main/docs/condition.md#Xor)] [[play](https://go.dev/play/p/gObZrW7ZbG8)] @@ -279,6 +279,8 @@ import "github.com/duke-git/lancet/v2/convertor" - **CopyProperties** : copies each field from the source struct into the destination struct. [[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#CopyProperties)] [[play](https://go.dev/play/p/oZujoB5Sgg5)] +- **ToInterface** : converts reflect value to its interface type. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToInterface)] ### 6. Cryptor package is for data encryption and decryption. @@ -401,6 +403,8 @@ import "github.com/duke-git/lancet/v2/datetime" - **AddMinute** : add or sub day to the time. [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime.md#AddMinute)] [[play](https://go.dev/play/p/nT1heB1KUUK)] +- **AddYear** : add or sub year to the time. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime.md#AddYear)] - **BeginOfMinute** : return the date time at the begin of minute of specific date. [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime.md#BeginOfMinute)] [[play](https://go.dev/play/p/ieOLVJ9CiFT)] @@ -482,6 +486,8 @@ import "github.com/duke-git/lancet/v2/datetime" - **ToIso8601** : return iso8601 time string. [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime.md#ToIso8601)] [[play](https://go.dev/play/p/mkhOHQkdeA2)] +- **IsLeapYear** : check if param `year` is leap year or not. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime.md#IsLeapYear)] ### 8. Datastructure package constains some common data structure. eg. list, linklist, stack, queue, set, tree, graph. @@ -787,6 +793,10 @@ import "github.com/duke-git/lancet/v2/mathutil" - **IsPrime** : checks if number is prime number. [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#IsPrime)] [[play](https://go.dev/play/p/Rdd8UTHZJ7u)] +- **GCD** : return greatest common divisor (GCD) of integers. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#GCD)] +- **LCM** : return Least Common Multiple (LCM) of integers. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#LCM)] ### 14. Netutil package contains functions to get net information and send http request. @@ -1193,6 +1203,8 @@ import "github.com/duke-git/lancet/v2/stream" - **FindFirst** : returns the first element of this stream and true, or zero value and false if the stream is empty. [[doc](https://github.com/duke-git/lancet/blob/main/docs/stream.md#FindFirst)] [[play](https://go.dev/play/p/9xEf0-6C1e3)] +- **FindLast** : returns the last element of this stream and true, or zero value and false if the stream is empty. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/stream.md#FindLast)] - **Max** : returns the maximum element of this stream according to the provided less function. less fuction: a > b [[doc](https://github.com/duke-git/lancet/blob/main/docs/stream.md#Max)] [[play](https://go.dev/play/p/fm-1KOPtGzn)] @@ -1345,6 +1357,12 @@ import "github.com/duke-git/lancet/v2/strutil" - **IndexOffset** : returns the index of the first instance of substr in string after offsetting the string by `idxFrom`. [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#IndexOffset)] [[play](https://go.dev/play/p/qZo4lV2fomB)] +- **ReplaceWithMap** : returns a copy of `str`, which is replaced by a map in unordered way, case-sensitively. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#ReplaceWithMap)] +- **Trim** : strips whitespace (or other characters) from the beginning and end of a string. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#Trim)] +- **SplitAndTrim** : splits string `str` by a string `delimiter` to a slice, and calls Trim to every element of slice. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#SplitAndTrim)] ### 21. System package contain some functions about os, runtime, shell command. diff --git a/README_zh-CN.md b/README_zh-CN.md index c53aa73..d1ac19c 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -208,7 +208,7 @@ import "github.com/duke-git/lancet/v2/condition" [[play](https://go.dev/play/p/g2j08F_zZky)] - **Xnor** : 如果 a 和 b 都是真的或 a 和 b 均是假的,则返回 true。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/condition_zh-CN.md#Xnor)] -[[play](https://go.dev/play/p/OuDB9g51643)] + [[play](https://go.dev/play/p/OuDB9g51643)] - **Nand** : 如果 a 和 b 都为真,返回 false,否则返回 true [[doc](https://github.com/duke-git/lancet/blob/main/docs/condition_zh-CN.md#Nand)] [[play](https://go.dev/play/p/vSRMLxLIbq8)] @@ -278,6 +278,8 @@ import "github.com/duke-git/lancet/v2/convertor" - **CopyProperties** : 拷贝不同结构体之间的同名字段。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#CopyProperties)] [[play](https://go.dev/play/p/oZujoB5Sgg5)] +- **ToInterface** : 将反射值转换成对应的 interface 类型。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToInterface)] ### 6. cryptor 加密包支持数据加密和解密,获取 md5,hash 值。支持 base64, md5, hmac, aes, des, rsa。 @@ -400,6 +402,8 @@ import "github.com/duke-git/lancet/v2/datetime" - **AddMinute** : 将日期加/减分钟数。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime_zh-CN.md#AddMinute)] [[play](https://go.dev/play/p/nT1heB1KUUK)] +- **AddYear** : 将日期加/减分年数。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime_zh-CN.md#AddYear)] - **BeginOfMinute** : 返回指定时间的分钟开始时间。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime_zh-CN.md#BeginOfMinute)] [[play](https://go.dev/play/p/ieOLVJ9CiFT)] @@ -475,12 +479,14 @@ import "github.com/duke-git/lancet/v2/datetime" - **ToFormat** : 返回格式'yyyy-mm-dd hh:mm:ss'的日期字符串。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime_zh-CN.md#ToFormat)] [[play](https://go.dev/play/p/VkW08ZOaXPZ)] -- **ToFormatForTpl** : 返回 tpl 格式指定的日期字符串。 +- **ToFormatForTpl** : 返回tpl格式指定的日期字符串。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime_zh-CN.md#ToFormatForTpl)] [[play](https://go.dev/play/p/nyXxXcQJ8L5)] -- **ToIso8601** : 返回 iso8601 日期字符串。 +- **ToIso8601** : 返回iso8601日期字符串。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime_zh-CN.md#ToIso8601)] [[play](https://go.dev/play/p/mkhOHQkdeA2)] +- **IsLeapYear** :验证是否是闰年。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime_zh-CN.md#IsLeapYear)] ### 8. datastructure 包含一些普通的数据结构实现。例如:list, linklist, stack, queue, set, tree, graph. @@ -786,6 +792,10 @@ import "github.com/duke-git/lancet/v2/mathutil" - **IsPrime** : 判断质数。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#IsPrime)] [[play](https://go.dev/play/p/Rdd8UTHZJ7u)] +- **GCD** : 求最大公约数。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#GCD)] +- **LCM** : 求最小公倍数。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#LCM)] ### 14. netutil 网络包支持获取 ip 地址,发送 http 请求。 @@ -1130,7 +1140,7 @@ import "github.com/duke-git/lancet/v2/slice" [[doc](https://github.com/duke-git/lancet/blob/main/docs/slice_zh-CN.md#KeyBy)] [[play](https://go.dev/play/p/uXod2LWD1Kg)] -### 18. Stream 流,该包仅验证简单的 stream 实现,功能有限。 +### 18. Stream流,该包仅验证简单的stream实现,功能有限。 ```go import "github.com/duke-git/lancet/v2/stream" @@ -1189,9 +1199,11 @@ import "github.com/duke-git/lancet/v2/stream" - **Reduce** : 使用关联累加函数对 stream 的元素执行 reduce 操作,并 reduce 操作结果(如果有)。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/stream_zh-CN.md#Reduce)] [[play](https://go.dev/play/p/6uzZjq_DJLU)] -- **FindFirst** : 返回此 stream 的第一个元素和 true,如果 stream 为空,则返回零值和 false。 +- **FindFirst** : 返回此 stream的第一个元素,如果 stream 为空,则返回零值和 false。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/stream_zh-CN.md#FindFirst)] [[play](https://go.dev/play/p/9xEf0-6C1e3)] +- **FindLast** : 返回此 stream的最后一个元素,如果 stream 为空,则返回零值和 false。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/stream_zh-CN.md#FindLast)] - **Max** : 根据提供的 less 函数返回 stream 的最大元素。less 函数: a > b [[doc](https://github.com/duke-git/lancet/blob/main/docs/stream_zh-CN.md#Max)] [[play](https://go.dev/play/p/fm-1KOPtGzn)] @@ -1347,6 +1359,12 @@ import "github.com/duke-git/lancet/v2/strutil" - **IndexOffset** : 将字符串偏移 idxFrom 后,返回字符串中第一个 substr 实例的索引。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#IndexOffset)] [[play](https://go.dev/play/p/qZo4lV2fomB)] +- **ReplaceWithMap** : 返回 string 的副本,以无序的方式被 map 替换,区分大小写。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#ReplaceWithMap)] +- **Trim** : 从字符串的开头和结尾去除空格(或其他字符)。 可选参数 characterMask 指定额外的剥离字符。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#Trim)] +- **SplitAndTrim** : 将字符串str按字符串delimiter拆分为一个切片,并对该数组的每个元素调用Trim。忽略Trim后为空的元素。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#SplitAndTrim)] ### 21. system 包含 os, runtime, shell command 的相关函数。 diff --git a/docs/datetime.md b/docs/datetime.md index 8a32db5..b6f80c9 100644 --- a/docs/datetime.md +++ b/docs/datetime.md @@ -1104,7 +1104,6 @@ func main() { } ``` - ### IsLeapYear
check if param `year` is leap year or not.
@@ -1136,4 +1135,4 @@ func main() { // true // false } -``` \ No newline at end of file +``` diff --git a/docs/strutil.md b/docs/strutil.md index aee09c3..30db7ff 100644 --- a/docs/strutil.md +++ b/docs/strutil.md @@ -1249,7 +1249,7 @@ func main() { ### SplitAndTrim -Splits string `str` by a string `delimiter` to a slice, and calls Trim to every element of this array. It ignores the elements which are empty after Trim.
+Splits string `str` by a string `delimiter` to a slice, and calls Trim to every element of slice. It ignores the elements which are empty after Trim.
Signature: diff --git a/docs/strutil_zh-CN.md b/docs/strutil_zh-CN.md index eab9464..2b1d935 100644 --- a/docs/strutil_zh-CN.md +++ b/docs/strutil_zh-CN.md @@ -1249,7 +1249,7 @@ func main() { ### SplitAndTrim -将字符串str按字符串 =delimiter拆分为一个切片,并对该数组的每个元素调用Trim。忽略Trim后为空的元素。
+将字符串str按字符串delimiter拆分为一个切片,并对该数组的每个元素调用Trim。忽略Trim后为空的元素。
函数签名: