diff --git a/README.md b/README.md
index a4a667dd..c33264de 100644
--- a/README.md
+++ b/README.md
@@ -364,10 +364,10 @@ import "github.com/duke-git/lancet/v2/cryptor"
[[play](https://go.dev/play/p/VtHxtkUj-3F)]
- **AesGcmEncrypt** : encrypt byte slice data with key use AES GCM algorithm.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/cryptor.md#AesGcmEncrypt)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/rUt0-DmsPCs)]
- **AesGcmDecrypt** : decrypt byte slice data with key use AES GCM algorithm.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/cryptor.md#AesGcmDecrypt)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/rUt0-DmsPCs)]
- **Base64StdEncode** : encode string with base64 encoding.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/cryptor.md#Base64StdEncode)]
[[play](https://go.dev/play/p/VOaUyQUreoK)]
@@ -611,13 +611,13 @@ import "github.com/duke-git/lancet/v2/datetime"
[[play](https://go.dev/play/p/A9Oq_COrcCF)]
- **TrackFuncTime** : tracks function execution time.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#TrackFuncTime)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/QBSEdfXHPTp)]
- **DaysBetween** : returns the number of days between two times.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#DaysBetween)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/qD6qGb3TbOy)]
- **GenerateDatetimesBetween** : returns a slice of strings between two times.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#GenerateDatetimesBetween)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/6kHBpAxD9ZC)]
8. Datastructure package contains some common data structure. eg. list, linklist, stack, queue, set, tree, graph. index
@@ -813,10 +813,10 @@ import "github.com/duke-git/lancet/v2/function"
[[play](https://go.dev/play/p/absuEGB_GN7)]
- **Debounce** : creates a debounced version of the provided function.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/function.md#Debounce)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/-dGFrYn_1Zi)]
- **Throttle** : creates a throttled version of the provided function.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/function.md#Throttle)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/HpoMov-tJSN)]
- **Schedule** : invoke function every duration time, util close the returned bool channel.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/function.md#Schedule)]
[[play](https://go.dev/play/p/hbON-Xeyn5N)]
@@ -937,58 +937,58 @@ import "github.com/duke-git/lancet/v2/maputil"
[[play](https://go.dev/play/p/0nlPo6YLdt3)]
- **NewOrderedMap** : creates a new OrderedMap.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#NewOrderedMap)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/Y4ZJ_oOc1FU)]
- **OrderedMap_Set** : sets the given key-value pair for ordered map.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Set)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/Y4ZJ_oOc1FU)]
- **OrderedMap_Get** : returns the value for the given key.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Get)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/Y4ZJ_oOc1FU)]
- **OrderedMap_Delete** : deletes the key-value pair for the given key.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Delete)]
- [[play](todo)]
+ [[play](ttps://go.dev/play/p/5bIi4yaZ3K-)]
- **OrderedMap_Clear** : clears the ordered map.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Clear)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/8LwoJyEfuFr)]
- **OrderedMap_Front** : returns the first key-value pair.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Front)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/ty57XSimpoe)]
- **OrderedMap_Back** : returns the last key-value pair.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Back)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/rQMjp1yQmpa)]
- **OrderedMap_Range** : calls the given function for each key-value pair.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Range)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/U-KpORhc7LZ)]
- **OrderedMap_Keys** : returns the keys in order.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Keys)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/Vv_y9ExKclA)]
- **OrderedMap_Values** : returns the values in order.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Values)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/TWj5n1-PUfx)]
- **OrderedMap_Elements** : returns the key-value pairs in order.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Elements)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/4BHG4kKz6bB)]
- **OrderedMap_Len** : returns the number of key-value pairs.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Len)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/cLe6z2VX5N-)]
- **OrderedMap_Contains** : returns true if the given key exists.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Contains)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/QuwqqnzwDNX)]
- **OrderedMap_Iter** : returns a channel that yields key-value pairs in order.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_Iter)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/tlq2tdvicPt)]
- **OrderedMap_ReverseIter** : returns a channel that yields key-value pairs in reverse order.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_ReverseIter)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/8Q0ssg6hZzO)]
- **OrderedMap_SortByKey** : sorts the map by key given less function.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_SortByKey)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/N7hjD_alZPq)]
- **OrderedMap_MarshalJSON** : implements the json.Marshaler interface.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_MarshalJSON)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/C-wAwydIAC7)]
- **OrderedMap_UnmarshalJSON** : implements the json.Unmarshaler interface.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#OrderedMap_UnmarshalJSON)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/t_pkwerIRVx)]
- **NewConcurrentMap** : creates a ConcurrentMap with specific shard count.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#NewConcurrentMap)]
[[play](https://go.dev/play/p/3PenTPETJT0)]
@@ -1015,10 +1015,10 @@ import "github.com/duke-git/lancet/v2/maputil"
[[play](https://go.dev/play/p/iqcy7P8P0Pr)]
- **SortByKey** : sorts the map by its keys and returns a new map with sorted keys.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#SortByKey)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/PVdmBSnm6P_W)]
- **GetOrDefault** : returns the value of the given key or a default value if the key is not present.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/maputil.md#GetOrDefault)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/99QjSYSBdiM)]
13. Mathutil package implements some functions for math calculation. index
@@ -1264,22 +1264,22 @@ import "github.com/duke-git/lancet/v2/random"
[[play](https://go.dev/play/p/I3yndUQ-rhh)]
- **RandStringSlice** : generate a slice of random string of length strLen based on charset.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandStringSlice)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/2_-PiDv3tGn)]
- **RandBool** : generate a random boolean value (true or false).
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandBool)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/to6BLc26wBv)]
- **RandBoolSlice** : generate a random boolean slice of specified length.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandBoolSlice)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/o-VSjPjnILI)]
- **RandIntSlice** : generate a slice of random int. Number range in [min, max)
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandIntSlice)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/GATTQ5xTEG8)]
- **RandFromGivenSlice** : generate a random element from given slice.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandFromGivenSlice)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/UrkWueF6yYo)]
- **RandSliceFromGivenSlice** : generate a random slice of length num from given slice.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandSliceFromGivenSlice)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/68UikN9d6VT)]
17. Retry package is for executing a function repeatedly until it was successful or canceled by the context. index
@@ -1424,7 +1424,7 @@ import "github.com/duke-git/lancet/v2/slice"
[[play](https://go.dev/play/p/qScs39f3D9W)]
- **ForEachConcurrent** : applies the iteratee function to each item in the slice concurrently.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#ForEachConcurrent)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/kT4XW7DKVoV)]
- **GroupBy** : iterate over elements of the slice, each element will be group by criteria, returns two slices.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#GroupBy)]
[[play](https://go.dev/play/p/QVkPxzPR0iA)]
@@ -1454,7 +1454,7 @@ import "github.com/duke-git/lancet/v2/slice"
[[play](https://go.dev/play/p/biaTefqPquw)]
- **MapConcurrent** : applies the iteratee function to each item in the slice by concrrent.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#MapConcurrent)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/H1ehfPkPen0)]
- **Merge** : merge all given slices into one slice.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#Merge)]
[[play](https://go.dev/play/p/lbjFp784r9N)]
@@ -1472,7 +1472,7 @@ import "github.com/duke-git/lancet/v2/slice"
[[play](https://go.dev/play/p/qT9dZC03A1K)]
- **ReduceConcurrent** : reduces the slice to a single value by applying the reducer function to each item in the slice concurrently.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#ReduceConcurrent)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/Tjwe6OtaG07)]
- **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/en/api/packages/slice.md#Replace)]
[[play](https://go.dev/play/p/P5mZp7IhOFo)]
@@ -1526,16 +1526,16 @@ import "github.com/duke-git/lancet/v2/slice"
[[play](https://go.dev/play/p/AXw0R3ZTE6a)]
- **UniqueBy** : remove duplicate elements from the input slice based on the values returned by the iteratee function.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#UniqueBy)]
- [[play](https://go.dev/play/p/UR323iZLDpv)]
+ [[play](https://go.dev/play/p/GY7JE4yikrl)]
- **UniqueByComparator** : remove duplicate elements from the input slice using the provided comparator function.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#UniqueByComparator)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/rwSacr-ZHsR)]
- **UniqueByField** : remove duplicate elements in struct slice by struct field.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#UniqueByField)]
[[play](https://go.dev/play/p/6cifcZSPIGu)]
- **UniqueByConcurrent** : remove duplicate elements from the slice by concurrent.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#UniqueByConcurrent)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/wXZ7LcYRMGL)]
- **Union** : creates a slice of unique elements, in order, from all given slices.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#Union)]
[[play](https://go.dev/play/p/hfXV1iRIZOf)]
@@ -1573,7 +1573,7 @@ import "github.com/duke-git/lancet/v2/slice"
[[play](https://go.dev/play/p/jlQVoelLl2k)]
- **Frequency** : counts the frequency of each element in the slice.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#Frequency)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/CW3UVNdUZOq)]
19. Stream package implements a sequence of elements supporting sequential and operations. this package is an experiment to explore if stream in go can work as the way java does. its function is very limited. index
@@ -1610,7 +1610,7 @@ import "github.com/duke-git/lancet/v2/stream"
[[play](https://go.dev/play/p/MFlSANo-buc)]
- **FilterConcurrent** : Applies the provided filter function `predicate` to each element of the input slice concurrently.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/stream.md#FilterConcurrent)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/t_pkwerIRVx)]
- **Map** : returns a stream consisting of the elements of this stream that apply the given function to elements of stream.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/stream.md#Map)]
[[play](https://go.dev/play/p/OtNQUImdYko)]
@@ -1830,19 +1830,23 @@ import "github.com/duke-git/lancet/v2/strutil"
[[play](https://go.dev/play/p/glNdQEA9HUi)]
- **Concat** : concatenates strings.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#Concat)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/gD52SZHr4Kp)]
- **Ellipsis** : truncates a string to a specified length and appends an ellipsis.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#Ellipsis)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/i1vbdQiQVRR)]
- **Shuffle** : shuffle the order of characters of given string.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#Shuffle)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/iStFwBwyGY7)]
- **Rotate** : rotates the string by the specified number of characters.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#Rotate)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/Kf03iOeT5bd)]
- **TemplateReplace** : replaces the placeholders in the template string with the corresponding values in the data map.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#TemplateReplace)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/cXSuFvyZqv9)]
+- **RegexMatchAllGroups** : matches all subgroups in a string using a regular expression and returns the result.
+ [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#RegexMatchAllGroups)]
+ [[play](https://go.dev/play/p/JZiu0RXpgN-)]
+
22. System package contain some functions about os, runtime, shell command. index
@@ -1881,16 +1885,16 @@ import "github.com/duke-git/lancet/v2/system"
[[play](https://go.dev/play/p/ml-_XH3gJbW)]
- **StartProcess** : start a new process with the specified name and arguments.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/system.md#StartProcess)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/5GVol6ryS_X)]
- **StopProcess** : stop a process by pid.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/system.md#StopProcess)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/jJZhRYGGcmD)]
- **KillProcess** : kill a new process with the specified name and arguments.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/system.md#KillProcess)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/XKmvV-ExBWa)]
- **GetProcessInfo** : retrieves detailed process information by pid.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/system.md#GetProcessInfo)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/NQDVywEYYx7)]
23. Tuple package implements tuple data type and some operations on it. index
diff --git a/README_zh-CN.md b/README_zh-CN.md
index 6a52993e..96d65eec 100644
--- a/README_zh-CN.md
+++ b/README_zh-CN.md
@@ -365,10 +365,10 @@ import "github.com/duke-git/lancet/v2/cryptor"
[[play](https://go.dev/play/p/VtHxtkUj-3F)]
- **AesGcmEncrypt** : 使用 AES GCM 算法模式加密数据。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/cryptor.md#AesGcmEncrypt)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/rUt0-DmsPCs)]
- **AesGcmDecrypt** : 使用 AES GCM 算法模式解密数据。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/cryptor.md#AesGcmDecrypt)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/rUt0-DmsPCs)]
- **Base64StdEncode** : 将字符串 base64 编码。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/cryptor.md#Base64StdEncode)]
[[play](https://go.dev/play/p/VOaUyQUreoK)]
@@ -614,13 +614,13 @@ import "github.com/duke-git/lancet/v2/datetime"
[[play](https://go.dev/play/p/A9Oq_COrcCF)]
- **TrackFuncTime** : 测试函数执行时间。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#TrackFuncTime)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/QBSEdfXHPTp)]
- **DaysBetween** : 返回两个日期之间的天数差。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#DaysBetween)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/qD6qGb3TbOy)]
- **GenerateDatetimesBetween** : 生成从start到end的所有日期时间的字符串列表。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#GenerateDatetimesBetween)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/6kHBpAxD9ZC)]
8. datastructure 包含一些普通的数据结构实现。例如:list, linklist, stack, queue, set, tree, graph。 回到目录
@@ -814,10 +814,10 @@ import "github.com/duke-git/lancet/v2/function"
[[play](https://go.dev/play/p/absuEGB_GN7)]
- **Debounce** : 创建一个函数的去抖动版本。该去抖动函数仅在上次调用后的指定延迟时间过去之后才会调用原始函数。支持取消去抖动。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/function.md#Debounce)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/-dGFrYn_1Zi)]
- **Throttle** : 创建一个函数的节流版本。返回的函数保证在每个时间间隔内最多只会被调用一次。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/function.md#Throttle)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/HpoMov-tJSN)]
- **Schedule** : 每次持续时间调用函数,直到关闭返回的 channel。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/function.md#Schedule)]
[[play](https://go.dev/play/p/hbON-Xeyn5N)]
@@ -939,58 +939,58 @@ import "github.com/duke-git/lancet/v2/maputil"
[[play](https://go.dev/play/p/0nlPo6YLdt3)]
- **NewOrderedMap** : 创建有序映射。有序映射是键值对的集合,其中键是唯一的,并且保留键插入的顺序。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#NewOrderedMap)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/Y4ZJ_oOc1FU)]
- **OrderedMap_Set** : 设置给定的键值对。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Set)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/Y4ZJ_oOc1FU)]
- **OrderedMap_Get** : 返回给定键的值。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Get)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/Y4ZJ_oOc1FU)]
- **OrderedMap_Delete** : 删除给定键的键值对。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Delete)]
- [[play](todo)]
+ [[play](ttps://go.dev/play/p/5bIi4yaZ3K-)]
- **OrderedMap_Clear** : 清空map数据。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Clear)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/8LwoJyEfuFr)]
- **OrderedMap_Front** : 返回第一个键值对。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Front)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/ty57XSimpoe)]
- **OrderedMap_Back** : 返回最后一个键值对。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Back)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/rQMjp1yQmpa)]
- **OrderedMap_Range** : 为每个键值对调用给定的函数。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Range)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/U-KpORhc7LZ)]
- **OrderedMap_Keys** : 按顺序返回键的切片。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Keys)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/Vv_y9ExKclA)]
- **OrderedMap_Values** : 按顺序返回值的切片。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Values)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/TWj5n1-PUfx)]
- **OrderedMap_Elements** : 按顺序返回键值对。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Elements)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/4BHG4kKz6bB)]
- **OrderedMap_Len** : 返回键值对的数量。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Len)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/cLe6z2VX5N-)]
- **OrderedMap_Contains** : 如果给定的键存在则返回true。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Contains)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/QuwqqnzwDNX)]
- **OrderedMap_Iter** : 返回按顺序产生键值对的通道。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_Iter)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/tlq2tdvicPt)]
- **OrderedMap_ReverseIter** : 返回以相反顺序产生键值对的通道。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_ReverseIter)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/8Q0ssg6hZzO)]
- **OrderedMap_SortByKey** : 使用传入的比较函数排序map key。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_SortByKey)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/N7hjD_alZPq)]
- **OrderedMap_MarshalJSON** : 实现json.Marshaler接口。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_MarshalJSON)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/C-wAwydIAC7)]
- **OrderedMap_UnmarshalJSON** : 实现json.Unmarshaler接口。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#OrderedMap_UnmarshalJSON)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/8C3MvJ3-mut)]
- **NewConcurrentMap** : ConcurrentMap 协程安全的 map 结构。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#NewConcurrentMap)]
[[play](https://go.dev/play/p/3PenTPETJT0)]
@@ -1017,10 +1017,10 @@ import "github.com/duke-git/lancet/v2/maputil"
[[play](https://go.dev/play/p/iqcy7P8P0Pr)]
- **SortByKey** : 对传入的map根据key进行排序。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#SortByKey)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/PVdmBSnm6P_W)]
- **GetOrDefault** : 返回给定键的值,如果键不存在,则返回默认值。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/maputil.md#GetOrDefault)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/99QjSYSBdiM)]
13. mathutil 包实现了一些数学计算的函数。 回到目录
@@ -1265,22 +1265,22 @@ import "github.com/duke-git/lancet/v2/random"
[[play](https://go.dev/play/p/uBkRSOz73Ec)]
- **RandStringSlice** : 生成随机字符串slice。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandStringSlice)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/2_-PiDv3tGn)]
- **RandBool** : 生成随机bool值(true or false)。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandBool)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/to6BLc26wBv)]
- **RandBoolSlice** : 生成特定长度的随机bool slice。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandBoolSlice)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/o-VSjPjnILI)]
- **RandIntSlice** : 生成一个特定长度的随机int切片,数值范围[min, max)。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandIntSlice)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/GATTQ5xTEG8)]
- **RandFromGivenSlice** : 从给定切片中随机生成元素。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandFromGivenSlice)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/UrkWueF6yYo)]
- **RandSliceFromGivenSlice** : 从给定切片中生成长度为 num 的随机切片。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandSliceFromGivenSlice)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/68UikN9d6VT)]
17. retry 重试执行函数直到函数运行成功或被 context cancel。 回到目录
@@ -1420,7 +1420,7 @@ import "github.com/duke-git/lancet/v2/slice"
[[play](https://go.dev/play/p/DrPaa4YsHRF)]
- **ForEachConcurrent** : 对slice并发执行foreach操作。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#ForEachConcurrent)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/kT4XW7DKVoV)]
- **ForEachWithBreak** : 遍历切片的元素并为每个元素调用 iteratee 函数,当 iteratee 函数返回 false 时,终止遍历。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#ForEachWithBreak)]
[[play](https://go.dev/play/p/qScs39f3D9W)]
@@ -1453,7 +1453,7 @@ import "github.com/duke-git/lancet/v2/slice"
[[play](https://go.dev/play/p/biaTefqPquw)]
- **MapConcurrent** : 对slice并发执行map操作。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#MapConcurrent)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/H1ehfPkPen0)]
- **Merge** : 合并多个切片(不会消除重复元素)。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#Merge)]
[[play](https://go.dev/play/p/lbjFp784r9N)]
@@ -1471,7 +1471,7 @@ import "github.com/duke-git/lancet/v2/slice"
[[play](https://go.dev/play/p/qT9dZC03A1K)]
- **ReduceConcurrent** : 对切片元素执行并发reduce操作。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#ReduceConcurrent)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/Tjwe6OtaG07)]
- **Replace** : 返回切片的副本,其中前 n 个不重叠的 old 替换为 new。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#Replace)]
[[play](https://go.dev/play/p/P5mZp7IhOFo)]
@@ -1525,16 +1525,16 @@ import "github.com/duke-git/lancet/v2/slice"
[[play](https://go.dev/play/p/AXw0R3ZTE6a)]
- **UniqueBy** : 根据迭代函数返回的值,从输入切片中移除重复元素。此函数保持元素的顺序。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#UniqueBy)]
- [[play](https://go.dev/play/p/UR323iZLDpv)]
+ [[play](https://go.dev/play/p/GY7JE4yikrl)]
- **UniqueByComparator** : 使用提供的比较器函数从输入切片中移除重复元素。此函数保持元素的顺序。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#UniqueByComparator)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/rwSacr-ZHsR)]
- **UniqueByField** : 根据struct字段对struct切片去重复。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#UniqueByField)]
[[play](https://go.dev/play/p/6cifcZSPIGu)]
- **UniqueByConcurrent** : 并发的从输入切片中移除重复元素,结果保持元素的顺序。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#UniqueByConcurrent)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/wXZ7LcYRMGL)]
- **Union** : 合并多个切片。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#Union)]
[[play](https://go.dev/play/p/hfXV1iRIZOf)]
@@ -1571,7 +1571,7 @@ import "github.com/duke-git/lancet/v2/slice"
[[play](https://go.dev/play/p/jlQVoelLl2k)]
- **Frequency** : 计算切片中每个元素出现的频率。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#Frequency)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/CW3UVNdUZOq)]
19. stream 流,该包仅验证简单的 stream 实现,功能有限。 回到目录
@@ -1608,7 +1608,7 @@ import "github.com/duke-git/lancet/v2/stream"
[[play](https://go.dev/play/p/MFlSANo-buc)]
- **FilterConcurrent** : 对slice并发执行filter操作。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/stream.md#FilterConcurrent)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/t_pkwerIRVx)]
- **Map** : 返回一个 stream,该 stream 由将给定函数应用于源 stream 元素的元素组成。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/stream.md#Map)]
[[play](https://go.dev/play/p/OtNQUImdYko)]
@@ -1832,19 +1832,22 @@ import "github.com/duke-git/lancet/v2/strutil"
[[play](https://go.dev/play/p/glNdQEA9HUi)]
- **Concat** : 拼接字符串。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#Concat)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/gD52SZHr4Kp)]
- **Ellipsis** : 将字符串截断到指定长度,并在末尾添加省略号。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#Ellipsis)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/i1vbdQiQVRR)]
- **Shuffle** : 打乱给定字符串中的字符顺序。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#Shuffle)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/iStFwBwyGY7)]
- **Rotate** : 按指定的字符数旋转字符串。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#Rotate)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/Kf03iOeT5bd)]
- **TemplateReplace** : 将模板字符串中的占位符替换为map中的相应值。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#TemplateReplace)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/cXSuFvyZqv9)]
+- **RegexMatchAllGroups** : 使用正则表达式匹配字符串中的所有子组并返回结果。
+ [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#RegexMatchAllGroups)]
+ [[play](https://go.dev/play/p/JZiu0RXpgN-)]
22. system 包含 os, runtime, shell command 的相关函数。 回到目录
@@ -1883,16 +1886,16 @@ import "github.com/duke-git/lancet/v2/system"
[[play](https://go.dev/play/p/ml-_XH3gJbW)]
- **StartProcess** :创建进程。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/system.md#StartProcess)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/5GVol6ryS_X)]
- **StopProcess** : 停止进程。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/system.md#StopProcess)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/jJZhRYGGcmD)]
- **KillProcess** : 杀掉进程。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/system.md#KillProcess)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/XKmvV-ExBWa)]
- **GetProcessInfo** : 根据进程id获取进程信息。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/system.md#GetProcessInfo)]
- [[play](todo)]
+ [[play](https://go.dev/play/p/NQDVywEYYx7)]
diff --git a/cryptor/crypto.go b/cryptor/crypto.go
index 9a1c6c85..f0ca3700 100644
--- a/cryptor/crypto.go
+++ b/cryptor/crypto.go
@@ -245,7 +245,7 @@ func AesOfbDecrypt(data, key []byte) []byte {
}
// AesGcmEncrypt encrypt data with key use AES GCM algorithm
-// Play: todo
+// Play: https://go.dev/play/p/rUt0-DmsPCs
func AesGcmEncrypt(data, key []byte) []byte {
block, err := aes.NewCipher(key)
if err != nil {
@@ -268,7 +268,7 @@ func AesGcmEncrypt(data, key []byte) []byte {
}
// AesGcmDecrypt decrypt data with key use AES GCM algorithm
-// Play: todo
+// Play: https://go.dev/play/p/rUt0-DmsPCs
func AesGcmDecrypt(data, key []byte) []byte {
block, err := aes.NewCipher(key)
if err != nil {
diff --git a/datetime/datetime.go b/datetime/datetime.go
index fe9d8368..dd6f4e14 100644
--- a/datetime/datetime.go
+++ b/datetime/datetime.go
@@ -385,7 +385,7 @@ func TimestampNano(timezone ...string) int64 {
// TrackFuncTime track the time of function execution.
// call it at top of the func like `defer TrackFuncTime(time.Now())()`
-// Play: todo
+// Play: https://go.dev/play/p/QBSEdfXHPTp
func TrackFuncTime(pre time.Time) func() {
callerName := getCallerName()
return func() {
@@ -413,7 +413,7 @@ func getCallerName() string {
}
// DaysBetween returns the number of days between two times.
-// Play: todo
+// Play: https://go.dev/play/p/qD6qGb3TbOy
func DaysBetween(start, end time.Time) int {
duration := end.Sub(start)
days := int(duration.Hours() / 24)
@@ -424,7 +424,7 @@ func DaysBetween(start, end time.Time) int {
// GenerateDatetimesBetween returns a slice of strings between two times.
// layout: the format of the datetime string
// interval: the interval between two datetimes
-// Play: todo
+// Play: https://go.dev/play/p/6kHBpAxD9ZC
func GenerateDatetimesBetween(start, end time.Time, layout string, interval string) ([]string, error) {
var result []string
diff --git a/docs/api/packages/cryptor.md b/docs/api/packages/cryptor.md
index 88826315..644aea5e 100644
--- a/docs/api/packages/cryptor.md
+++ b/docs/api/packages/cryptor.md
@@ -391,7 +391,7 @@ func main() {
func AesGcmEncrypt(data, key []byte) []byte
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/rUt0-DmsPCs)
```go
package main
@@ -425,7 +425,7 @@ func main() {
func AesGcmDecrypt(data, key []byte) []byte
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/rUt0-DmsPCs)
```go
package main
diff --git a/docs/api/packages/datetime.md b/docs/api/packages/datetime.md
index a9ead3c3..e41f8183 100644
--- a/docs/api/packages/datetime.md
+++ b/docs/api/packages/datetime.md
@@ -1479,7 +1479,7 @@ func main() {
func TrackFuncTime(pre time.Time) func()
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/QBSEdfXHPTp)
```go
package main
@@ -1511,7 +1511,7 @@ func main() {
func DaysBetween(start, end time.Time) int
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/qD6qGb3TbOy)
```go
package main
@@ -1544,7 +1544,7 @@ func main() {
func GenerateDatetimesBetween(start, end time.Time, layout string, interval string) ([]string, error)
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/6kHBpAxD9ZC)
```go
package main
diff --git a/docs/api/packages/function.md b/docs/api/packages/function.md
index 1db408be..c20e35bb 100644
--- a/docs/api/packages/function.md
+++ b/docs/api/packages/function.md
@@ -205,7 +205,7 @@ func main() {
func Debounce(fn func(), delay time.Duration) (debouncedFn func(), cancelFn func())
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/-dGFrYn_1Zi)
```go
package main
@@ -753,7 +753,7 @@ func main() {
func Throttle(fn func(), interval time.Duration) func()
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/HpoMov-tJSN)
```go
package main
diff --git a/docs/api/packages/maputil.md b/docs/api/packages/maputil.md
index 46424549..8173a0d9 100644
--- a/docs/api/packages/maputil.md
+++ b/docs/api/packages/maputil.md
@@ -1191,7 +1191,7 @@ func main() {
func (om *OrderedMap[K, V]) Set(key K, value V)
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/Y4ZJ_oOc1FU)
```go
package main
@@ -1230,7 +1230,7 @@ func main() {
func (om *OrderedMap[K, V]) Get(key K) (V, bool)
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/Y4ZJ_oOc1FU)
```go
package main
@@ -1270,7 +1270,7 @@ func main() {
func (om *OrderedMap[K, V]) Delete(key K)
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/5bIi4yaZ3K-)
```go
package main
@@ -1306,7 +1306,7 @@ func main() {
func (om *OrderedMap[K, V]) Clear()
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/8LwoJyEfuFr)
```go
package main
@@ -1345,7 +1345,7 @@ func (om *OrderedMap[K, V]) Front() (struct {
}, bool)
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/ty57XSimpoe)
```go
package main
@@ -1385,7 +1385,7 @@ func (om *OrderedMap[K, V]) Back() (struct {
}, bool)
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/rQMjp1yQmpa)
```go
package main
@@ -1402,12 +1402,12 @@ func main() {
om.Set("b", 2)
om.Set("c", 3)
- frontElement, ok := om.Front()
- fmt.Println(frontElement)
+ backElement, ok := om.Back()
+ fmt.Println(backElement)
fmt.Println(ok)
// Output:
- // {a 1}
+ // {c 3}
// true
}
```
@@ -1422,7 +1422,7 @@ func main() {
func (om *OrderedMap[K, V]) Range(iteratee func(key K, value V) bool)
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/U-KpORhc7LZ)
```go
package main
@@ -1461,7 +1461,7 @@ func main() {
func (om *OrderedMap[K, V]) Keys() []K
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/Vv_y9ExKclA)
```go
package main
@@ -1497,7 +1497,7 @@ func main() {
func (om *OrderedMap[K, V]) Values() []V
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/TWj5n1-PUfx)
```go
package main
@@ -1533,7 +1533,7 @@ func main() {
func (om *OrderedMap[K, V]) Elements() []struct
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/4BHG4kKz6bB)
```go
package main
@@ -1569,7 +1569,7 @@ func main() {
func (om *OrderedMap[K, V]) Len() int
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/cLe6z2VX5N-)
```go
package main
@@ -1605,7 +1605,7 @@ func main() {
func (om *OrderedMap[K, V]) Contains(key K) bool
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/QuwqqnzwDNX)
```go
package main
@@ -1647,7 +1647,7 @@ func (om *OrderedMap[K, V]) Iter() <-chan struct {
}
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/tlq2tdvicPt)
```go
package main
@@ -1688,7 +1688,7 @@ func (om *OrderedMap[K, V]) ReverseIter() <-chan struct {
}
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/8Q0ssg6hZzO)
```go
package main
@@ -1726,7 +1726,7 @@ func main() {
func (om *OrderedMap[K, V]) SortByKey(less func(a, b K) bool)
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/N7hjD_alZPq)
```go
package main
@@ -1737,7 +1737,7 @@ import (
)
func main() {
- om := maputil.NewOrderedMap[string, int]()
+ om := maputil.NewOrderedMap[int, string]()
om.Set(3, "c")
om.Set(1, "a")
@@ -1765,7 +1765,7 @@ func main() {
func (om *OrderedMap[K, V]) MarshalJSON() ([]byte, error)
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/C-wAwydIAC7)
```go
package main
@@ -1776,7 +1776,7 @@ import (
)
func main() {
- om := maputil.NewOrderedMap[string, int]()
+ om := maputil.NewOrderedMap[int, string]()
om.Set(3, "c")
om.Set(1, "a")
@@ -1802,7 +1802,7 @@ func main() {
func (om *OrderedMap[K, V]) UnmarshalJSON(data []byte) error
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/8C3MvJ3-mut)
```go
package main
@@ -1822,6 +1822,7 @@ func main() {
fmt.Println(om.Elements())
// Output:
+ // [{a 1} {b 2} {c 3}]
}
```
@@ -2239,7 +2240,7 @@ func main() {
func SortByKey[K constraints.Ordered, V any](m map[K]V) (sortedKeysMap map[K]V)
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/PVdmBSnm6P_W)
```go
package main
@@ -2257,7 +2258,9 @@ func main() {
2: "b",
}
- result := maputil.SortByKey(m)
+ result := maputil.SortByKey(m, func(a, b int) bool {
+ return a < b
+ })
fmt.Println(result)
@@ -2276,7 +2279,7 @@ func main() {
func GetOrDefault[K comparable, V any](m map[K]V, key K, defaultValue V) V
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/99QjSYSBdiM)
```go
package main
diff --git a/docs/api/packages/random.md b/docs/api/packages/random.md
index 9b943608..895f1ba5 100644
--- a/docs/api/packages/random.md
+++ b/docs/api/packages/random.md
@@ -134,7 +134,7 @@ func main() {
func RandFromGivenSlice[T any](slice []T) T
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/UrkWueF6yYo)
```go
package main
@@ -161,7 +161,7 @@ func main() {
func RandSliceFromGivenSlice[T any](slice []T, num int, repeatable bool) []T
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/68UikN9d6VT)
```go
package main
@@ -172,9 +172,11 @@ import (
)
func main() {
- goods := []string{"apple", "banana", "cherry", "elderberry", "fig", "grape", "honeydew", "kiwi", "lemon","mango", "nectarine", "orange"}
- chosen3goods := random.RandSliceFromGivenSlice(goods, 3, false)
- fmt.Println(chosen3goods)
+ goods := []string{"apple", "banana", "cherry", "elderberry", "fig", "grape", "honeydew", "kiwi", "lemon","mango", "nectarine", "orange"}
+
+ chosen3goods := random.RandSliceFromGivenSlice(goods, 3, false)
+
+ fmt.Println(chosen3goods)
}
```
@@ -347,7 +349,7 @@ func main() {
func RandIntSlice(length, min, max int) []int
```
-示例:
+示例:[运行](https://go.dev/play/p/GATTQ5xTEG8)
```go
package main
@@ -451,7 +453,7 @@ func main() {
func RandStringSlice(charset string, sliceLen, strLen int) []string
```
-实例:[运行](todo)
+实例:[运行](https://go.dev/play/p/2_-PiDv3tGn)
```go
package main
@@ -480,7 +482,7 @@ func main() {
func RandBool() bool
```
-实例:[运行](todo)
+实例:[运行](https://go.dev/play/p/to6BLc26wBv)
```go
package main
@@ -506,7 +508,7 @@ func main() {
func RandBoolSlice(length int) []bool
```
-实例:[运行](todo)
+实例:[运行](https://go.dev/play/p/o-VSjPjnILI)
```go
package main
diff --git a/docs/api/packages/slice.md b/docs/api/packages/slice.md
index a6341b65..2714f5c4 100644
--- a/docs/api/packages/slice.md
+++ b/docs/api/packages/slice.md
@@ -915,7 +915,7 @@ func main() {
func FilterConcurrent[T any](slice []T, predicate func(index int, item T) bool, numThreads int) []T
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/t_pkwerIRVx)
```go
import (
@@ -1192,7 +1192,7 @@ func main() {
func ForEachConcurrent[T any](slice []T, iteratee func(index int, item T), numThreads int)
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/kT4XW7DKVoV)
```go
import (
@@ -1570,7 +1570,7 @@ func main() {
func MapConcurrent[T any, U any](slice []T, iteratee func(index int, item T) U, numThreads int) []U
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/H1ehfPkPen0)
```go
import (
@@ -1771,7 +1771,7 @@ func main() {
func ReduceConcurrent[T any](slice []T, initial T, reducer func(index int, item T, agg T) T, numThreads int) T
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/Tjwe6OtaG07)
```go
import (
@@ -2449,7 +2449,7 @@ func main() {
func UniqueBy[T any, U comparable](slice []T, iteratee func(item T) U) []T
```
-示例:[运行](https://go.dev/play/p/UR323iZLDpv)
+示例:[运行](https://go.dev/play/p/GY7JE4yikrl)
```go
import (
@@ -2480,7 +2480,7 @@ func main() {
func UniqueByComparator[T comparable](slice []T, comparator func(item T, other T) bool) []T
```
-示例:
+示例:[运行](https://go.dev/play/p/rwSacr-ZHsR)
```go
import (
@@ -2516,7 +2516,7 @@ func main() {
func UniqueByConcurrent[T comparable](slice []T, comparator func(item T, other T) bool, numThreads int) []T
```
-示例:
+示例:[运行](https://go.dev/play/p/wXZ7LcYRMGL)
```go
import (
@@ -2967,7 +2967,7 @@ func main() {
func Frequency[T comparable](slice []T) map[T]int
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/CW3UVNdUZOq)
```go
import (
diff --git a/docs/api/packages/strutil.md b/docs/api/packages/strutil.md
index 54d6bd36..3e214e3c 100644
--- a/docs/api/packages/strutil.md
+++ b/docs/api/packages/strutil.md
@@ -1547,7 +1547,7 @@ func main() {
func Concat(length int, str ...string) string
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/gD52SZHr4Kp)
```go
import (
@@ -1556,10 +1556,10 @@ import (
)
func main() {
-
- result1 := strutil.Concat(12, "Hello", " ", "World", "!")
+ result1 := strutil.Concat(12, "Hello", " ", "World", "!")
result2 := strutil.Concat(11, "Go", " ", "Language")
result3 := strutil.Concat(0, "An apple a ", "day,", "keeps the", " doctor away")
+
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
@@ -1581,7 +1581,7 @@ func main() {
func Ellipsis(str string, length int) string
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/i1vbdQiQVRR)
```go
import (
@@ -1615,7 +1615,7 @@ func main() {
func Shuffle(str string) string
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/iStFwBwyGY7)
```go
import (
@@ -1639,7 +1639,7 @@ func main() {
func Rotate(str string, shift int) string
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/Kf03iOeT5bd)
```go
import (
@@ -1648,9 +1648,9 @@ import (
)
func main() {
- result1 := Rotate("Hello", 0)
- result2 := Rotate("Hello", 1)
- result3 := Rotate("Hello", 2)
+ result1 := strutil.Rotate("Hello", 0)
+ result2 := strutil.Rotate("Hello", 1)
+ result3 := strutil.Rotate("Hello", 2)
fmt.Println(result1)
fmt.Println(result2)
@@ -1673,7 +1673,7 @@ func main() {
func TemplateReplace(template string, data map[string]string) string
```
-示例:[运行]()
+示例:[运行](https://go.dev/play/p/cXSuFvyZqv9)
```go
import (
@@ -1707,7 +1707,7 @@ func main() {
func RegexMatchAllGroups(pattern, str string) [][]string
```
-示例:[Run](todo)
+示例:[Run](https://go.dev/play/p/JZiu0RXpgN-)
```go
import (
diff --git a/docs/api/packages/system.md b/docs/api/packages/system.md
index 45fb0b2c..937a8f0c 100644
--- a/docs/api/packages/system.md
+++ b/docs/api/packages/system.md
@@ -324,7 +324,7 @@ func main() {
func StartProcess(command string, args ...string) (int, error)
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/5GVol6ryS_X)
```go
import (
@@ -352,7 +352,7 @@ func main() {
func StopProcess(pid int) error
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/jJZhRYGGcmD)
```go
import (
@@ -386,7 +386,7 @@ func main() {
func KillProcess(pid int) error
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/XKmvV-ExBWa)
```go
import (
@@ -420,7 +420,7 @@ func main() {
func GetProcessInfo(pid int) (*ProcessInfo, error)
```
-示例:[运行](todo)
+示例:[运行](https://go.dev/play/p/NQDVywEYYx7)
```go
import (
diff --git a/docs/en/api/packages/cryptor.md b/docs/en/api/packages/cryptor.md
index 7b564ca8..72854d93 100644
--- a/docs/en/api/packages/cryptor.md
+++ b/docs/en/api/packages/cryptor.md
@@ -391,7 +391,7 @@ func main() {
func AesGcmEncrypt(data, key []byte) []byte
```
-Example:[Run]()
+Example:[Run](https://go.dev/play/p/rUt0-DmsPCs)
```go
package main
@@ -425,7 +425,7 @@ func main() {
func AesGcmDecrypt(data, key []byte) []byte
```
-Example:[Run]()
+Example:[Run](https://go.dev/play/p/rUt0-DmsPCs)
```go
package main
diff --git a/docs/en/api/packages/datetime.md b/docs/en/api/packages/datetime.md
index 184355d8..762cef8f 100644
--- a/docs/en/api/packages/datetime.md
+++ b/docs/en/api/packages/datetime.md
@@ -1480,7 +1480,7 @@ func main() {
func TrackFuncTime(pre time.Time) func()
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/QBSEdfXHPTp)
```go
package main
@@ -1512,7 +1512,7 @@ func main() {
func DaysBetween(start, end time.Time) int
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/qD6qGb3TbOy)
```go
package main
@@ -1545,7 +1545,7 @@ func main() {
func GenerateDatetimesBetween(start, end time.Time, layout string, interval string) ([]string, error)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/6kHBpAxD9ZC)
```go
package main
diff --git a/docs/en/api/packages/function.md b/docs/en/api/packages/function.md
index 1eca185a..cf6d165c 100644
--- a/docs/en/api/packages/function.md
+++ b/docs/en/api/packages/function.md
@@ -204,7 +204,7 @@ func main() {
func Debounce(fn func(), delay time.Duration) (debouncedFn func(), cancelFn func())
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/-dGFrYn_1Zi)
```go
package main
@@ -752,7 +752,7 @@ func main() {
func Throttle(fn func(), interval time.Duration) func()
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/HpoMov-tJSN)
```go
package main
diff --git a/docs/en/api/packages/maputil.md b/docs/en/api/packages/maputil.md
index 6c2b447c..ccaa86b6 100644
--- a/docs/en/api/packages/maputil.md
+++ b/docs/en/api/packages/maputil.md
@@ -1167,7 +1167,7 @@ func main() {
func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V]
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/99QjSYSBdiM)
```go
package main
@@ -1206,7 +1206,7 @@ func main() {
func (om *OrderedMap[K, V]) Set(key K, value V)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/Y4ZJ_oOc1FU)
```go
package main
@@ -1245,7 +1245,7 @@ func main() {
func (om *OrderedMap[K, V]) Get(key K) (V, bool)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/Y4ZJ_oOc1FU)
```go
package main
@@ -1285,7 +1285,7 @@ func main() {
func (om *OrderedMap[K, V]) Delete(key K)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/5bIi4yaZ3K-)
```go
package main
@@ -1321,7 +1321,7 @@ func main() {
func (om *OrderedMap[K, V]) Clear()
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/8LwoJyEfuFr)
```go
package main
@@ -1360,7 +1360,7 @@ func (om *OrderedMap[K, V]) Front() (struct {
}, bool)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/ty57XSimpoe)
```go
package main
@@ -1400,7 +1400,7 @@ func (om *OrderedMap[K, V]) Back() (struct {
}, bool)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/rQMjp1yQmpa)
```go
package main
@@ -1417,12 +1417,12 @@ func main() {
om.Set("b", 2)
om.Set("c", 3)
- frontElement, ok := om.Front()
- fmt.Println(frontElement)
+ backElement, ok := om.Back()
+ fmt.Println(backElement)
fmt.Println(ok)
// Output:
- // {a 1}
+ // {c 3}
// true
}
```
@@ -1437,7 +1437,7 @@ func main() {
func (om *OrderedMap[K, V]) Range(iteratee func(key K, value V) bool)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/U-KpORhc7LZ)
```go
package main
@@ -1476,7 +1476,7 @@ func main() {
func (om *OrderedMap[K, V]) Keys() []K
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/Vv_y9ExKclA)
```go
package main
@@ -1512,7 +1512,7 @@ func main() {
func (om *OrderedMap[K, V]) Values() []V
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/TWj5n1-PUfx)
```go
package main
@@ -1548,7 +1548,7 @@ func main() {
func (om *OrderedMap[K, V]) Elements() []struct
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/4BHG4kKz6bB)
```go
package main
@@ -1584,7 +1584,7 @@ func main() {
func (om *OrderedMap[K, V]) Len() int
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/cLe6z2VX5N-)
```go
package main
@@ -1620,7 +1620,7 @@ func main() {
func (om *OrderedMap[K, V]) Contains(key K) bool
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/QuwqqnzwDNX)
```go
package main
@@ -1662,7 +1662,7 @@ func (om *OrderedMap[K, V]) Iter() <-chan struct {
}
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/tlq2tdvicPt)
```go
package main
@@ -1703,7 +1703,7 @@ func (om *OrderedMap[K, V]) ReverseIter() <-chan struct {
}
```
-Example:[Run]()
+Example:[Run](https://go.dev/play/p/8Q0ssg6hZzO)
```go
package main
@@ -1741,7 +1741,7 @@ func main() {
func (om *OrderedMap[K, V]) SortByKey(less func(a, b K) bool)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/N7hjD_alZPq)
```go
package main
@@ -1752,7 +1752,7 @@ import (
)
func main() {
- om := maputil.NewOrderedMap[string, int]()
+ om := maputil.NewOrderedMap[int, string]()
om.Set(3, "c")
om.Set(1, "a")
@@ -1780,7 +1780,7 @@ func main() {
func (om *OrderedMap[K, V]) MarshalJSON() ([]byte, error)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/C-wAwydIAC7)
```go
package main
@@ -1791,7 +1791,7 @@ import (
)
func main() {
- om := maputil.NewOrderedMap[string, int]()
+ om := maputil.NewOrderedMap[int, string]()
om.Set(3, "c")
om.Set(1, "a")
@@ -1817,7 +1817,7 @@ func main() {
func (om *OrderedMap[K, V]) UnmarshalJSON(data []byte) error
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/8C3MvJ3-mut)
```go
package main
@@ -1837,6 +1837,7 @@ func main() {
fmt.Println(om.Elements())
// Output:
+ // [{a 1} {b 2} {c 3}]
}
```
@@ -2256,7 +2257,7 @@ func main() {
func SortByKey[K constraints.Ordered, V any](m map[K]V) (sortedKeysMap map[K]V)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/PVdmBSnm6P_W)
```go
package main
@@ -2274,7 +2275,9 @@ func main() {
2: "b",
}
- result := maputil.SortByKey(m)
+ result := maputil.SortByKey(m, func(a, b int) bool {
+ return a < b
+ })
fmt.Println(result)
@@ -2293,7 +2296,7 @@ func main() {
func GetOrDefault[K comparable, V any](m map[K]V, key K, defaultValue V) V
```
-Example:[运行](todo)
+Example:[运行](https://go.dev/play/p/99QjSYSBdiM)
```go
package main
diff --git a/docs/en/api/packages/random.md b/docs/en/api/packages/random.md
index d735f37b..ae5a611d 100644
--- a/docs/en/api/packages/random.md
+++ b/docs/en/api/packages/random.md
@@ -133,7 +133,7 @@ func main() {
func RandFromGivenSlice[T any](slice []T) T
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/UrkWueF6yYo)
```go
package main
@@ -160,7 +160,7 @@ func main() {
func RandSliceFromGivenSlice[T any](slice []T, num int, repeatable bool) []T
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/68UikN9d6VT)
```go
package main
@@ -171,8 +171,10 @@ import (
)
func main() {
- goods := []string{"apple", "banana", "cherry", "elderberry", "fig", "grape", "honeydew", "kiwi", "lemon", "mango", "nectarine", "orange"}
- chosen3goods := random.RandSliceFromGivenSlice(goods, 3, false)
+ goods := []string{"apple", "banana", "cherry", "elderberry", "fig", "grape", "honeydew", "kiwi", "lemon", "mango", "nectarine", "orange"}
+
+ chosen3goods := random.RandSliceFromGivenSlice(goods, 3, false)
+
fmt.Println(chosen3goods)
}
```
@@ -346,7 +348,7 @@ func main() {
func RandIntSlice(length, min, max int) []int
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/GATTQ5xTEG8)
```go
package main
@@ -452,7 +454,7 @@ func main() {
func RandStringSlice(charset string, sliceLen, strLen int) []string
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/2_-PiDv3tGn)
```go
package main
@@ -481,7 +483,7 @@ func main() {
func RandBool() bool
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/to6BLc26wBv)
```go
package main
@@ -507,7 +509,7 @@ func main() {
func RandBoolSlice(length int) []bool
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/o-VSjPjnILI)
```go
package main
diff --git a/docs/en/api/packages/slice.md b/docs/en/api/packages/slice.md
index a4d5cadf..5d580e42 100644
--- a/docs/en/api/packages/slice.md
+++ b/docs/en/api/packages/slice.md
@@ -913,7 +913,7 @@ func main() {
func FilterConcurrent[T any](slice []T, predicate func(index int, item T) bool, numThreads int) []T
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/t_pkwerIRVx)
```go
import (
@@ -1190,7 +1190,7 @@ func main() {
func ForEachConcurrent[T any](slice []T, iteratee func(index int, item T), numThreads int)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/kT4XW7DKVoV)
```go
import (
@@ -1567,7 +1567,7 @@ func main() {
func MapConcurrent[T any, U any](slice []T, iteratee func(index int, item T) U, numThreads int) []U
```
-Example:
+Example:[Run](https://go.dev/play/p/H1ehfPkPen0)
```go
import (
@@ -1766,7 +1766,7 @@ func main() {
func ReduceConcurrent[T any](slice []T, initial T, reducer func(index int, item T, agg T) T, numThreads int) T
```
-Example:[运行](todo)
+Example:[运行](https://go.dev/play/p/Tjwe6OtaG07)
```go
import (
@@ -2445,7 +2445,7 @@ func main() {
func UniqueBy[T any, U comparable](slice []T, iteratee func(item T) U) []T
```
-Example:[Run](https://go.dev/play/p/UR323iZLDpv)
+Example:[Run](https://go.dev/play/p/GY7JE4yikrl)
```go
import (
@@ -2476,7 +2476,7 @@ func main() {
func UniqueByComparator[T comparable](slice []T, comparator func(item T, other T) bool) []T
```
-Example:
+Example:[Run](https://go.dev/play/p/rwSacr-ZHsR)
```go
import (
@@ -2512,7 +2512,7 @@ func main() {
func UniqueByConcurrent[T comparable](slice []T, comparator func(item T, other T) bool, numThreads int) []T
```
-Example:
+Example:[Runs](https://go.dev/play/p/wXZ7LcYRMGL)
```go
import (
@@ -2962,7 +2962,7 @@ func main() {
func Frequency[T comparable](slice []T) map[T]int
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/CW3UVNdUZOq)
```go
import (
diff --git a/docs/en/api/packages/strutil.md b/docs/en/api/packages/strutil.md
index a31afd51..c0154158 100644
--- a/docs/en/api/packages/strutil.md
+++ b/docs/en/api/packages/strutil.md
@@ -1549,7 +1549,7 @@ func main() {
func Concat(length int, str ...string) string
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/gD52SZHr4Kp)
```go
import (
@@ -1561,6 +1561,7 @@ func main() {
result1 := strutil.Concat(12, "Hello", " ", "World", "!")
result2 := strutil.Concat(11, "Go", " ", "Language")
result3 := strutil.Concat(0, "An apple a ", "day,", "keeps the", " doctor away")
+
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
@@ -1582,7 +1583,7 @@ func main() {
func Ellipsis(str string, length int) string
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/i1vbdQiQVRR)
```go
import (
@@ -1616,7 +1617,7 @@ func main() {
func Shuffle(str string) string
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/iStFwBwyGY7)
```go
import (
@@ -1640,7 +1641,7 @@ func main() {
func Rotate(str string, shift int) string
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/Kf03iOeT5bd)
```go
import (
@@ -1673,7 +1674,7 @@ func main() {
func TemplateReplace(template string, data map[string]string string
```
-example:[Run](todo)
+example:[Run](https://go.dev/play/p/cXSuFvyZqv9)
```go
import (
@@ -1707,7 +1708,7 @@ func main() {
func RegexMatchAllGroups(pattern, str string) [][]string
```
-example:[Run](todo)
+example:[Run](https://go.dev/play/p/JZiu0RXpgN-)
```go
import (
diff --git a/docs/en/api/packages/system.md b/docs/en/api/packages/system.md
index 4a99a058..290aa317 100644
--- a/docs/en/api/packages/system.md
+++ b/docs/en/api/packages/system.md
@@ -325,7 +325,7 @@ func main() {
func StartProcess(command string, args ...string) (int, error)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/5GVol6ryS_X)
```go
import (
@@ -353,7 +353,7 @@ func main() {
func StopProcess(pid int) error
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/jJZhRYGGcmD)
```go
import (
@@ -387,7 +387,7 @@ func main() {
func KillProcess(pid int) error
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/XKmvV-ExBWa)
```go
import (
@@ -421,7 +421,7 @@ func main() {
func GetProcessInfo(pid int) (*ProcessInfo, error)
```
-Example:[Run](todo)
+Example:[Run](https://go.dev/play/p/NQDVywEYYx7)
```go
import (
diff --git a/docs/en/guide/getting_started.md b/docs/en/guide/getting_started.md
index c61ccf50..6c1aa8b6 100644
--- a/docs/en/guide/getting_started.md
+++ b/docs/en/guide/getting_started.md
@@ -10,7 +10,7 @@ outline: deep
go get github.com/duke-git/lancet/v2 // will install latest version of v2.x.x
```
-2. For users who use version below go1.18, you should install v1.x.x. The latest of v1.x.x is v1.4.1.
+2. For users who use version below go1.18, you should install v1.x.x. The latest of v1.x.x is v1.4.4.
```go
go get github.com/duke-git/lancet // below go1.18, install latest version of v1.x.x
diff --git a/docs/guide/getting_started.md b/docs/guide/getting_started.md
index c04ec23e..7d13cb42 100644
--- a/docs/guide/getting_started.md
+++ b/docs/guide/getting_started.md
@@ -10,7 +10,7 @@ outline: deep
go get github.com/duke-git/lancet/v2 // will install latest version of v2.x.x
```
-2. 使用 go1.18 以下版本的用户,必须安装 v1.x.x。目前最新的 v1 版本是 v1.4.1。
+2. 使用 go1.18 以下版本的用户,必须安装 v1.x.x。目前最新的 v1 版本是 v1.4.4。
```go
go get github.com/duke-git/lancet // below go1.18, install latest version of v1.x.x
diff --git a/function/function.go b/function/function.go
index 9075c551..e063d6df 100644
--- a/function/function.go
+++ b/function/function.go
@@ -93,7 +93,7 @@ func Debounced(fn func(), delay time.Duration) func() {
}
// Debounce creates a debounced version of the provided function.
-// Play: todo
+// Play: https://go.dev/play/p/-dGFrYn_1Zi
func Debounce(fn func(), delay time.Duration) (debouncedFn func(), cancelFn func()) {
var (
timer *time.Timer
@@ -127,7 +127,7 @@ func Debounce(fn func(), delay time.Duration) (debouncedFn func(), cancelFn func
// Throttle creates a throttled version of the provided function.
// The returned function guarantees that it will only be invoked at most once per interval.
-// Play: todo
+// Play: https://go.dev/play/p/HpoMov-tJSN
func Throttle(fn func(), interval time.Duration) func() {
var (
timer *time.Timer
diff --git a/maputil/map.go b/maputil/map.go
index 363a1091..db351905 100644
--- a/maputil/map.go
+++ b/maputil/map.go
@@ -455,7 +455,7 @@ func GetOrSet[K comparable, V any](m map[K]V, key K, value V) V {
}
// SortByKey sorts the map by its keys and returns a new map with sorted keys.
-// Play: todo
+// Play: https://go.dev/play/p/PVdmBSnm6P_W
func SortByKey[K constraints.Ordered, V any](m map[K]V, less func(a, b K) bool) (sortedKeysMap map[K]V) {
keys := make([]K, 0, len(m))
for k := range m {
@@ -659,7 +659,7 @@ func convertMap(src reflect.Value, dst reflect.Value) error {
}
// GetOrDefault returns the value of the given key or a default value if the key is not present.
-// Play: todo
+// Play: https://go.dev/play/p/99QjSYSBdiM
func GetOrDefault[K comparable, V any](m map[K]V, key K, defaultValue V) V {
if v, ok := m[key]; ok {
return v
diff --git a/maputil/orderedmap.go b/maputil/orderedmap.go
index b62d3818..d16e67cd 100644
--- a/maputil/orderedmap.go
+++ b/maputil/orderedmap.go
@@ -29,7 +29,7 @@ func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V] {
}
// Sets the given key-value pair.
-// Play: todo
+// Play: https://go.dev/play/p/Y4ZJ_oOc1FU
func (om *OrderedMap[K, V]) Set(key K, value V) {
om.mu.Lock()
defer om.mu.Unlock()
@@ -48,7 +48,7 @@ func (om *OrderedMap[K, V]) Set(key K, value V) {
}
// Get returns the value for the given key.
-// Play: todo
+// Play: https://go.dev/play/p/Y4ZJ_oOc1FU
func (om *OrderedMap[K, V]) Get(key K) (V, bool) {
om.mu.RLock()
defer om.mu.RUnlock()
@@ -59,7 +59,7 @@ func (om *OrderedMap[K, V]) Get(key K) (V, bool) {
}
// Delete deletes the given key.
-// Play: todo
+// Play: https://go.dev/play/p/5bIi4yaZ3K-
func (om *OrderedMap[K, V]) Delete(key K) {
om.mu.Lock()
defer om.mu.Unlock()
@@ -72,7 +72,7 @@ func (om *OrderedMap[K, V]) Delete(key K) {
}
// Clear clears the map.
-// Play: todo
+// Play: https://go.dev/play/p/8LwoJyEfuFr
func (om *OrderedMap[K, V]) Clear() {
om.mu.Lock()
defer om.mu.Unlock()
@@ -83,7 +83,7 @@ func (om *OrderedMap[K, V]) Clear() {
}
// Front returns the first key-value pair.
-// Play: todo
+// Play: https://go.dev/play/p/ty57XSimpoe
func (om *OrderedMap[K, V]) Front() (struct {
Key K
Value V
@@ -111,7 +111,7 @@ func (om *OrderedMap[K, V]) Front() (struct {
}
// Back returns the last key-value pair.
-// Play: todo
+// Play: https://go.dev/play/p/rQMjp1yQmpa
func (om *OrderedMap[K, V]) Back() (struct {
Key K
Value V
@@ -139,7 +139,7 @@ func (om *OrderedMap[K, V]) Back() (struct {
}
// Range calls the given function for each key-value pair.
-// Play: todo
+// Play: https://go.dev/play/p/U-KpORhc7LZ
func (om *OrderedMap[K, V]) Range(iteratee func(key K, value V) bool) {
om.mu.RLock()
defer om.mu.RUnlock()
@@ -155,7 +155,7 @@ func (om *OrderedMap[K, V]) Range(iteratee func(key K, value V) bool) {
}
// Keys returns the keys in order.
-// Play: todo
+// Play: https://go.dev/play/p/Vv_y9ExKclA
func (om *OrderedMap[K, V]) Keys() []K {
om.mu.RLock()
defer om.mu.RUnlock()
@@ -170,7 +170,7 @@ func (om *OrderedMap[K, V]) Keys() []K {
}
// Values returns the values in order.
-// Play: todo
+// Play: https://go.dev/play/p/TWj5n1-PUfx
func (om *OrderedMap[K, V]) Values() []V {
om.mu.RLock()
defer om.mu.RUnlock()
@@ -186,7 +186,7 @@ func (om *OrderedMap[K, V]) Values() []V {
}
// Len returns the number of key-value pairs.
-// Play: todo
+// Play: https://go.dev/play/p/cLe6z2VX5N-
func (om *OrderedMap[K, V]) Len() int {
om.mu.RLock()
defer om.mu.RUnlock()
@@ -195,7 +195,7 @@ func (om *OrderedMap[K, V]) Len() int {
}
// Contains returns true if the given key exists.
-// Play: todo
+// Play: https://go.dev/play/p/QuwqqnzwDNX
func (om *OrderedMap[K, V]) Contains(key K) bool {
om.mu.RLock()
defer om.mu.RUnlock()
@@ -206,7 +206,7 @@ func (om *OrderedMap[K, V]) Contains(key K) bool {
}
// Elements returns the key-value pairs in order.
-// Play: todo
+// Play: https://go.dev/play/p/4BHG4kKz6bB
func (om *OrderedMap[K, V]) Elements() []struct {
Key K
Value V
@@ -232,7 +232,7 @@ func (om *OrderedMap[K, V]) Elements() []struct {
}
// Iter returns a channel that yields key-value pairs in order.
-// Play: todo
+// Play: https://go.dev/play/p/tlq2tdvicPt
func (om *OrderedMap[K, V]) Iter() <-chan struct {
Key K
Value V
@@ -262,7 +262,7 @@ func (om *OrderedMap[K, V]) Iter() <-chan struct {
}
// ReverseIter returns a channel that yields key-value pairs in reverse order.
-// Play: todo
+// Play: https://go.dev/play/p/8Q0ssg6hZzO
func (om *OrderedMap[K, V]) ReverseIter() <-chan struct {
Key K
Value V
@@ -292,7 +292,7 @@ func (om *OrderedMap[K, V]) ReverseIter() <-chan struct {
}
// SortByValue sorts the map by key given less function.
-// Play: todo
+// Play: https://go.dev/play/p/N7hjD_alZPq
func (om *OrderedMap[K, V]) SortByKey(less func(a, b K) bool) {
om.mu.Lock()
defer om.mu.Unlock()
@@ -315,7 +315,7 @@ func (om *OrderedMap[K, V]) SortByKey(less func(a, b K) bool) {
}
// MarshalJSON implements the json.Marshaler interface.
-// Play: todo
+// Play: https://go.dev/play/p/C-wAwydIAC7
func (om *OrderedMap[K, V]) MarshalJSON() ([]byte, error) {
om.mu.RLock()
defer om.mu.RUnlock()
@@ -334,7 +334,7 @@ func (om *OrderedMap[K, V]) MarshalJSON() ([]byte, error) {
}
// UnmarshalJSON implements the json.Unmarshaler interface.
-// Play: todo
+// Play: https://go.dev/play/p/8C3MvJ3-mut
func (om *OrderedMap[K, V]) UnmarshalJSON(data []byte) error {
om.mu.Lock()
defer om.mu.Unlock()
diff --git a/random/random.go b/random/random.go
index 0174daf0..51923821 100644
--- a/random/random.go
+++ b/random/random.go
@@ -33,13 +33,13 @@ func init() {
}
// RandBool generates a random boolean value (true or false).
-// Play: todo
+// Play: https://go.dev/play/p/to6BLc26wBv
func RandBool() bool {
return rand.Intn(2) == 1
}
// RandBoolSlice generates a random boolean slice of specified length.
-// Play: todo
+// Play: https://go.dev/play/p/o-VSjPjnILI
func RandBoolSlice(length int) []bool {
if length <= 0 {
return []bool{}
@@ -73,7 +73,7 @@ func RandInt(min, max int) int {
// RandIntSlice generates a slice of random integers.
// The generated integers are between min and max (exclusive).
-// Play: todo
+// Play: https://go.dev/play/p/GATTQ5xTEG8
func RandIntSlice(length, min, max int) []int {
if length <= 0 || min > max {
return []int{}
@@ -170,7 +170,7 @@ func RandString(length int) string {
// RandString generate a slice of random string of length strLen based on charset.
// chartset should be one of the following: random.Numeral, random.LowwerLetters, random.UpperLetters
// random.Letters, random.SymbolChars, random.AllChars. or a combination of them.
-// Play: todo
+// Play: https://go.dev/play/p/2_-PiDv3tGn
func RandStringSlice(charset string, sliceLen, strLen int) []string {
if sliceLen <= 0 || strLen <= 0 {
return []string{}
@@ -186,7 +186,7 @@ func RandStringSlice(charset string, sliceLen, strLen int) []string {
}
// RandFromGivenSlice generate a random element from given slice.
-// Play: todo
+// Play: https://go.dev/play/p/UrkWueF6yYo
func RandFromGivenSlice[T any](slice []T) T {
if len(slice) == 0 {
var zero T
@@ -198,7 +198,7 @@ func RandFromGivenSlice[T any](slice []T) T {
// RandSliceFromGivenSlice generate a random slice of length num from given slice.
// - If repeatable is true, the generated slice may contain duplicate elements.
//
-// Play: todo
+// Play: https://go.dev/play/p/68UikN9d6VT
func RandSliceFromGivenSlice[T any](slice []T, num int, repeatable bool) []T {
if num <= 0 || len(slice) == 0 {
return slice
diff --git a/slice/slice.go b/slice/slice.go
index 7847b266..a5e00d6b 100644
--- a/slice/slice.go
+++ b/slice/slice.go
@@ -789,7 +789,7 @@ func Unique[T comparable](slice []T) []T {
// UniqueBy removes duplicate elements from the input slice based on the values returned by the iteratee function.
// The function maintains the order of the elements.
-// Play: todo
+// Play: https://go.dev/play/p/GY7JE4yikrl
func UniqueBy[T any, U comparable](slice []T, iteratee func(item T) U) []T {
result := make([]T, 0, len(slice))
seen := make(map[U]struct{}, len(slice))
@@ -810,7 +810,7 @@ func UniqueBy[T any, U comparable](slice []T, iteratee func(item T) U) []T {
// UniqueByComparator removes duplicate elements from the input slice using the provided comparator function.
// The function maintains the order of the elements.
-// Play: todo
+// Play: https://go.dev/play/p/rwSacr-ZHsR
func UniqueByComparator[T comparable](slice []T, comparator func(item T, other T) bool) []T {
result := make([]T, 0, len(slice))
seen := make([]T, 0, len(slice))
@@ -1388,7 +1388,7 @@ func LeftPadding[T any](slice []T, paddingValue T, paddingLength int) []T {
}
// Frequency counts the frequency of each element in the slice.
-// Play: todo
+// Play: https://go.dev/play/p/CW3UVNdUZOq
func Frequency[T comparable](slice []T) map[T]int {
result := make(map[T]int)
diff --git a/slice/slice_concurrent.go b/slice/slice_concurrent.go
index e5d40ffb..62167393 100644
--- a/slice/slice_concurrent.go
+++ b/slice/slice_concurrent.go
@@ -9,7 +9,7 @@ import (
)
// ForEachConcurrent applies the iteratee function to each item in the slice concurrently.
-// Play: todo
+// Play: https://go.dev/play/p/kT4XW7DKVoV
func ForEachConcurrent[T any](slice []T, iteratee func(index int, item T), numThreads int) {
sliceLen := len(slice)
if sliceLen == 0 {
@@ -50,7 +50,7 @@ func ForEachConcurrent[T any](slice []T, iteratee func(index int, item T), numTh
}
// MapConcurrent applies the iteratee function to each item in the slice concurrently.
-// Play: todo
+// Play: https://go.dev/play/p/H1ehfPkPen0
func MapConcurrent[T any, U any](slice []T, iteratee func(index int, item T) U, numThreads int) []U {
result := make([]U, len(slice))
var wg sync.WaitGroup
@@ -77,7 +77,7 @@ func MapConcurrent[T any, U any](slice []T, iteratee func(index int, item T) U,
}
// ReduceConcurrent reduces the slice to a single value by applying the reducer function to each item in the slice concurrently.
-// Play: todo
+// Play: https://go.dev/play/p/Tjwe6OtaG07
func ReduceConcurrent[T any](slice []T, initial T, reducer func(index int, item T, agg T) T, numThreads int) T {
if numThreads <= 0 {
numThreads = 1
@@ -121,7 +121,7 @@ func ReduceConcurrent[T any](slice []T, initial T, reducer func(index int, item
}
// FilterConcurrent applies the provided filter function `predicate` to each element of the input slice concurrently.
-// Play: todo
+// Play: https://go.dev/play/p/t_pkwerIRVx
func FilterConcurrent[T any](slice []T, predicate func(index int, item T) bool, numThreads int) []T {
result := make([]T, 0)
var wg sync.WaitGroup
@@ -154,7 +154,7 @@ func FilterConcurrent[T any](slice []T, predicate func(index int, item T) bool,
// The numThreads parameter specifies the number of threads to use
// If numThreads is less than or equal to 0, it will be set to 1
// The comparator function should return true if the two elements are equal
-// Play: todo
+// Play: https://go.dev/play/p/wXZ7LcYRMGL
func UniqueByConcurrent[T comparable](slice []T, comparator func(item T, other T) bool, numThreads int) []T {
if numThreads <= 0 {
numThreads = 1
diff --git a/strutil/string.go b/strutil/string.go
index a8eb6c63..28a43c00 100644
--- a/strutil/string.go
+++ b/strutil/string.go
@@ -627,7 +627,7 @@ func HammingDistance(a, b string) (int, error) {
// - `length` is the expected length of the concatenated string.
// - if you are unsure about the length of the string to be concatenated, please pass 0 or a negative number.
//
-// Play: todo
+// Play: https://go.dev/play/p/gD52SZHr4Kp
func Concat(length int, str ...string) string {
if len(str) == 0 {
return ""
@@ -647,7 +647,7 @@ func Concat(length int, str ...string) string {
}
// Ellipsis truncates a string to a specified length and appends an ellipsis.
-// Play: todo
+// Play: https://go.dev/play/p/i1vbdQiQVRR
func Ellipsis(str string, length int) string {
str = strings.TrimSpace(str)
@@ -665,7 +665,7 @@ func Ellipsis(str string, length int) string {
}
// Shuffle the order of characters of given string.
-// Play: todo
+// Play: https://go.dev/play/p/iStFwBwyGY7
func Shuffle(str string) string {
runes := []rune(str)
@@ -678,7 +678,7 @@ func Shuffle(str string) string {
}
// Rotate rotates the string by the specified number of characters.
-// Play: todo
+// Play: https://go.dev/play/p/Kf03iOeT5bd
func Rotate(str string, shift int) string {
if shift == 0 {
return str
@@ -709,7 +709,7 @@ func Rotate(str string, shift int) string {
// The placeholders are enclosed in curly braces, e.g. {key}.
// for example, the template string is "Hello, {name}!", and the data map is {"name": "world"},
// the result will be "Hello, world!".
-// Play: todo
+// Play: https://go.dev/play/p/cXSuFvyZqv9
func TemplateReplace(template string, data map[string]string) string {
re := regexp.MustCompile(`\{(\w+)\}`)
@@ -729,7 +729,7 @@ func TemplateReplace(template string, data map[string]string) string {
}
// RegexMatchAllGroups Matches all subgroups in a string using a regular expression and returns the result.
-// Play: todo
+// Play: https://go.dev/play/p/JZiu0RXpgN-
func RegexMatchAllGroups(pattern, str string) [][]string {
re := regexp.MustCompile(pattern)
matches := re.FindAllStringSubmatch(str, -1)
diff --git a/system/os.go b/system/os.go
index 669f8d88..641e43fe 100644
--- a/system/os.go
+++ b/system/os.go
@@ -137,7 +137,7 @@ func GetOsBits() int {
}
// StartProcess start a new process with the specified name and arguments.
-// Play: todo
+// Play: https://go.dev/play/p/5GVol6ryS_X
func StartProcess(command string, args ...string) (int, error) {
cmd := exec.Command(command, args...)
@@ -149,7 +149,7 @@ func StartProcess(command string, args ...string) (int, error) {
}
// StopProcess stop a process by pid.
-// Play: todo
+// Play: https://go.dev/play/p/jJZhRYGGcmD
func StopProcess(pid int) error {
process, err := os.FindProcess(pid)
if err != nil {
@@ -160,7 +160,7 @@ func StopProcess(pid int) error {
}
// KillProcess kill a process by pid.
-// Play: todo
+// Play: https://go.dev/play/p/XKmvV-ExBWa
func KillProcess(pid int) error {
process, err := os.FindProcess(pid)
if err != nil {
@@ -186,7 +186,7 @@ type ProcessInfo struct {
}
// GetProcessInfo retrieves detailed process information by pid.
-// Play: todo
+// Play: https://go.dev/play/p/NQDVywEYYx7
func GetProcessInfo(pid int) (*ProcessInfo, error) {
var cmd *exec.Cmd