diff --git a/docs/.vitepress/en.ts b/docs/.vitepress/en.ts index 47af998..a7714aa 100644 --- a/docs/.vitepress/en.ts +++ b/docs/.vitepress/en.ts @@ -94,6 +94,9 @@ export const enConfig: LocaleSpecificConfig = { { text: 'maputil', link: '/en/api/packages/maputil' }, { text: 'netutil', link: '/en/api/packages/netutil' }, { text: 'pointer', link: '/en/api/packages/pointer' }, + { text: 'random', link: '/en/api/packages/random' }, + { text: 'retry', link: '/en/api/packages/retry' }, + { text: 'slice', link: '/en/api/packages/slice' }, ], }, ], diff --git a/docs/.vitepress/zh.ts b/docs/.vitepress/zh.ts index 4750e9c..acbeda5 100644 --- a/docs/.vitepress/zh.ts +++ b/docs/.vitepress/zh.ts @@ -107,6 +107,9 @@ export const zhConfig: LocaleSpecificConfig = { { text: 'Map', link: '/api/packages/maputil' }, { text: '网络', link: '/api/packages/netutil' }, { text: '指针', link: '/api/packages/pointer' }, + { text: '随机数', link: '/api/packages/random' }, + { text: '重试', link: '/api/packages/retry' }, + { text: '切片', link: '/api/packages/slice' }, ], }, ], diff --git a/docs/olddocs/random_zh-CN.md b/docs/api/packages/random.md similarity index 81% rename from docs/olddocs/random_zh-CN.md rename to docs/api/packages/random.md index a3debdf..28c3e95 100644 --- a/docs/olddocs/random_zh-CN.md +++ b/docs/api/packages/random.md @@ -34,6 +34,8 @@ import (
+ + ## 文档 ### RandBytes @@ -46,7 +48,7 @@ import ( func RandBytes(length int) []byte ``` -示例: +示例:[运行](https://go.dev/play/p/EkiLESeXf8d) ```go package main @@ -72,7 +74,7 @@ func main() { func RandInt(min, max int) int ``` -示例: +示例:[运行](https://go.dev/play/p/pXyyAAI5YxD) ```go package main @@ -98,7 +100,7 @@ func main() { func RandString(length int) string ``` -示例: +示例:[运行](https://go.dev/play/p/W2xvRUXA7Mi) ```go package main @@ -124,7 +126,7 @@ func main() { func RandUpper(length int) string ``` -示例: +示例:[运行](https://go.dev/play/p/29QfOh0DVuh) ```go package main @@ -150,7 +152,7 @@ func main() { func RandLower(length int) string ``` -示例: +示例:[运行](https://go.dev/play/p/XJtZ471cmtI) ```go package main @@ -176,7 +178,7 @@ func main() { func RandNumeral(length int) string ``` -示例: +示例:[运行](https://go.dev/play/p/g4JWVpHsJcf) ```go package main @@ -202,7 +204,7 @@ func main() { func RandNumeralOrLetter(length int) string ``` -示例: +示例:[运行](https://go.dev/play/p/19CEQvpx2jD) ```go package main @@ -228,7 +230,7 @@ func main() { func UUIdV4() (string, error) ``` -示例: +示例:[运行](https://go.dev/play/p/_Z9SFmr28ft) ```go package main @@ -257,7 +259,7 @@ func main() { func RandUniqueIntSlice(n, min, max int) []int ``` -示例: +示例:[运行](https://go.dev/play/p/uBkRSOz73Ec) ```go package main diff --git a/docs/olddocs/retry_zh-CN.md b/docs/api/packages/retry.md similarity index 88% rename from docs/olddocs/retry_zh-CN.md rename to docs/api/packages/retry.md index 677fafa..f61bf41 100644 --- a/docs/olddocs/retry_zh-CN.md +++ b/docs/api/packages/retry.md @@ -30,7 +30,9 @@ import (
-## Document 文档 + + +## 文档 ### Context @@ -42,7 +44,7 @@ import ( func Context(ctx context.Context) ``` -示例: +示例:[运行](https://go.dev/play/p/xnAOOXv9GkS) ```go import ( @@ -89,7 +91,7 @@ func main() { type RetryFunc func() error ``` -示例: +示例:[运行](https://go.dev/play/p/nk2XRmagfVF) ```go package main @@ -135,7 +137,7 @@ func main() { func RetryTimes(n uint) ``` -示例: +示例:[运行](https://go.dev/play/p/ssfVeU2SwLO) ```go package main @@ -178,7 +180,7 @@ func main() { func RetryDuration(d time.Duration) ``` -示例: +示例:[运行](https://go.dev/play/p/nk2XRmagfVF) ```go package main @@ -224,7 +226,7 @@ func main() { func Retry(retryFunc RetryFunc, opts ...Option) error ``` -示例: +示例:[运行](https://go.dev/play/p/nk2XRmagfVF) ```go package main diff --git a/docs/olddocs/slice_zh-CN.md b/docs/api/packages/slice.md similarity index 86% rename from docs/olddocs/slice_zh-CN.md rename to docs/api/packages/slice.md index ee842a8..7d87432 100644 --- a/docs/olddocs/slice_zh-CN.md +++ b/docs/api/packages/slice.md @@ -94,6 +94,8 @@ import (
+ + ## 文档 ### AppendIfAbsent @@ -106,7 +108,7 @@ import ( func AppendIfAbsent[T comparable](slice []T, item T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/GNdv7Jg2Taj) ```go import ( @@ -137,7 +139,7 @@ func main() { func Contain[T comparable](slice []T, target T) bool ``` -示例: +示例:[运行](https://go.dev/play/p/_454yEHcNjf) ```go import ( @@ -168,7 +170,7 @@ func main() { func ContainBy[T any](slice []T, predicate func(item T) bool) bool ``` -示例: +示例:[运行](https://go.dev/play/p/49tkHfX4GNc) ```go import ( @@ -213,7 +215,7 @@ func main() { func ContainSubSlice[T comparable](slice, subSlice []T) bool ``` -示例: +示例:[运行](https://go.dev/play/p/bcuQ3UT6Sev) ```go import ( @@ -244,7 +246,7 @@ func main() { func Chunk[T any](slice []T, size int) [][]T ``` -示例: +示例:[运行](https://go.dev/play/p/b4Pou5j2L_C) ```go import ( @@ -286,7 +288,7 @@ func main() { func Compact[T comparable](slice []T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/pO5AnxEr3TK) ```go import ( @@ -323,7 +325,7 @@ func main() { func Concat[T any](slice []T, slices ...[]T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/gPt-q7zr5mk) ```go import ( @@ -354,7 +356,7 @@ func main() { func Count[T comparable](slice []T, item T) int ``` -示例: +示例:[运行](https://go.dev/play/p/Mj4oiEnQvRJ) ```go import ( @@ -387,7 +389,7 @@ func main() { func CountBy[T any](slice []T, predicate func(index int, item T) bool) int ``` -示例: +示例:[运行](https://go.dev/play/p/tHOccTMDZCC) ```go import ( @@ -421,7 +423,7 @@ func main() { func Difference[T comparable](slice, comparedSlice []T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/VXvadzLzhDa) ```go import ( @@ -452,7 +454,7 @@ func main() { func DifferenceBy[T comparable](slice []T, comparedSlice []T, iteratee func(index int, item T) T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/DiivgwM5OnC) ```go import ( @@ -487,7 +489,7 @@ func main() { func DifferenceWith[T any](slice []T, comparedSlice []T, comparator func(value, otherValue T) bool) []T ``` -示例: +示例:[运行](https://go.dev/play/p/v2U2deugKuV) ```go import ( @@ -522,7 +524,7 @@ func main() { func DeleteAt[T any](slice []T, start int, end ...int) ``` -示例: +示例:[运行](https://go.dev/play/p/pJ-d6MUWcvK) ```go import ( @@ -557,7 +559,7 @@ func main() { func Drop[T any](slice []T, n int) []T ``` -示例: +示例:[运行](https://go.dev/play/p/jnPO2yQsT8H) ```go import ( @@ -594,7 +596,7 @@ func main() { func DropRight[T any](slice []T, n int) []T ``` -示例: +示例:[运行](https://go.dev/play/p/8bcXvywZezG) ```go import ( @@ -631,7 +633,7 @@ func main() { func DropWhile[T any](slice []T, predicate func(item T) bool) []T ``` -示例: +示例:[运行](https://go.dev/play/p/4rt252UV_qs) ```go import ( @@ -671,7 +673,7 @@ func main() { func DropRightWhile[T any](slice []T, predicate func(item T) bool) []T ``` -示例: +示例:[运行](https://go.dev/play/p/6wyK3zMY56e) ```go import ( @@ -713,7 +715,7 @@ func main() { func Every[T any](slice []T, predicate func(index int, item T) bool) bool ``` -示例: +示例:[运行](https://go.dev/play/p/R8U6Sl-j8cD) ```go import ( @@ -747,7 +749,7 @@ func main() { func Equal[T comparable](slice1, slice2 []T) bool ``` -示例: +示例:[运行](https://go.dev/play/p/WcRQJ37ifPa) ```go import ( @@ -782,7 +784,7 @@ func main() { func EqualWith[T, U any](slice1 []T, slice2 []U, comparator func(T, U) bool) bool ``` -示例: +示例:[运行](https://go.dev/play/p/b9iygtgsHI1) ```go import ( @@ -817,7 +819,7 @@ func main() { func Filter[T any](slice []T, predicate func(index int, item T) bool) []T ``` -示例: +示例:[运行](https://go.dev/play/p/SdPna-7qK4T) ```go import ( @@ -851,7 +853,7 @@ func main() { func Find[T any](slice []T, predicate func(index int, item T) bool) (*T, bool) ``` -示例: +示例:[运行](https://go.dev/play/p/CBKeBoHVLgq) ```go import ( @@ -887,7 +889,7 @@ func main() { func FindBy[T any](slice []T, predicate func(index int, item T) bool) (v T, ok bool) ``` -示例: +示例:[运行](https://go.dev/play/p/n1lysBYl-GB) ```go import ( @@ -923,7 +925,7 @@ func main() { func FindLast[T any](slice []T, predicate func(index int, item T) bool) (*T, bool) ``` -示例: +示例:[运行](https://go.dev/play/p/FFDPV_j7URd) ```go import ( @@ -959,7 +961,7 @@ func main() { func FindLastBy[T any](slice []T, predicate func(index int, item T) bool) (v T, ok bool) ``` -示例: +示例:[运行](https://go.dev/play/p/8iqomzyCl_s) ```go import ( @@ -995,7 +997,7 @@ func main() { func Flatten(slice any) any ``` -示例: +示例:[运行](https://go.dev/play/p/hYa3cBEevtm) ```go import ( @@ -1025,7 +1027,7 @@ func main() { func FlattenDeep(slice any) any ``` -示例: +示例:[运行](https://go.dev/play/p/yjYNHPyCFaF) ```go import ( @@ -1055,7 +1057,7 @@ func main() { func ForEach[T any](slice []T, iteratee func(index int, item T)) ``` -示例: +示例:[运行](https://go.dev/play/p/DrPaa4YsHRF) ```go import ( @@ -1090,7 +1092,7 @@ func main() { func ForEachWithBreak[T any](slice []T, iteratee func(index int, item T) bool) ``` -示例: +示例:[运行](https://go.dev/play/p/qScs39f3D9W) ```go import ( @@ -1128,7 +1130,7 @@ func main() { func GroupBy[T any](slice []T, groupFn func(index int, item T) bool) ([]T, []T) ``` -示例: +示例:[运行](https://go.dev/play/p/QVkPxzPR0iA) ```go import ( @@ -1164,7 +1166,7 @@ func main() { func GroupWith[T any, U comparable](slice []T, iteratee func(T) U) map[U][]T ``` -示例: +示例:[运行](https://go.dev/play/p/ApCvMNTLO8a) ```go import ( @@ -1198,7 +1200,7 @@ func main() { func IntSlice(slice any) []int ``` -示例: +示例:[运行](https://go.dev/play/p/UQDj-on9TGN) ```go import ( @@ -1227,7 +1229,7 @@ func main() { func InterfaceSlice(slice any) []any ``` -示例: +示例:[运行](https://go.dev/play/p/FdQXF0Vvqs-) ```go import ( @@ -1256,7 +1258,7 @@ func main() { func Intersection[T comparable](slices ...[]T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/anJXfB5wq_t) ```go import ( @@ -1287,7 +1289,7 @@ func main() { func InsertAt[T any](slice []T, index int, value any) []T ``` -示例: +示例:[运行](https://go.dev/play/p/hMLNxPEGJVE) ```go import ( @@ -1327,7 +1329,7 @@ func main() { func IndexOf[T comparable](slice []T, item T) int ``` -示例: +示例:[运行](https://go.dev/play/p/MRN1f0FpABb) ```go import ( @@ -1360,7 +1362,7 @@ func main() { func LastIndexOf[T comparable](slice []T, item T) int ``` -示例: +示例:[运行](https://go.dev/play/p/DokM4cf1IKH) ```go import ( @@ -1393,7 +1395,7 @@ func main() { func Map[T any, U any](slice []T, iteratee func(index int, item T) U) []U ``` -示例: +示例:[运行](https://go.dev/play/p/biaTefqPquw) ```go import ( @@ -1427,7 +1429,7 @@ func main() { func FilterMap[T any, U any](slice []T, iteratee func(index int, item T) (U, bool)) []U ``` -示例: +示例:[运行](https://go.dev/play/p/J94SZ_9MiIe) ```go import ( @@ -1464,7 +1466,7 @@ func main() { func FlatMap[T any, U any](slice []T, iteratee func(index int, item T) []U) []U ``` -示例: +示例:[运行](https://go.dev/play/p/_QARWlWs1N_F) ```go import ( @@ -1497,7 +1499,7 @@ func main() { func Merge[T any](slices ...[]T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/lbjFp784r9N) ```go import ( @@ -1528,7 +1530,7 @@ func main() { func Reverse[T any](slice []T) ``` -示例: +示例:[运行](https://go.dev/play/p/8uI8f1lwNrQ) ```go import ( @@ -1558,7 +1560,7 @@ func main() { func Reduce[T any](slice []T, iteratee func(index int, item1, item2 T) T, initial T) T ``` -示例: +示例:[运行](https://go.dev/play/p/_RfXJJWIsIm) ```go import ( @@ -1592,7 +1594,7 @@ func main() { func ReduceBy[T any, U any](slice []T, initial U, reducer func(index int, item T, agg U) U) U ``` -示例: +示例:[运行](https://go.dev/play/p/YKDpLi7gtee) ```go import ( @@ -1628,7 +1630,7 @@ func main() { func ReduceRight[T any, U any](slice []T, initial U, reducer func(index int, item T, agg U) U) U ``` -示例: +示例:[运行](https://go.dev/play/p/qT9dZC03A1K) ```go import ( @@ -1658,7 +1660,7 @@ func main() { func Replace[T comparable](slice []T, old T, new T, n int) []T ``` -示例: +示例:[运行](https://go.dev/play/p/P5mZp7IhOFo) ```go import ( @@ -1700,7 +1702,7 @@ func main() { func ReplaceAll[T comparable](slice []T, old T, new T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/CzqXMsuYUrx) ```go import ( @@ -1728,7 +1730,7 @@ func main() { func Repeat[T any](item T, n int) []T ``` -示例: +示例:[运行](https://go.dev/play/p/1CbOmtgILUU) ```go import ( @@ -1756,7 +1758,7 @@ func main() { func Shuffle[T any](slice []T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/YHvhnWGU3Ge) ```go import ( @@ -1785,7 +1787,7 @@ func main() { func IsAscending[T constraints.Ordered](slice []T) bool ``` -示例: +示例:[运行](https://go.dev/play/p/9CtsFjet4SH) ```go import ( @@ -1819,7 +1821,7 @@ func main() { func IsDescending[T constraints.Ordered](slice []T) bool ``` -示例: +示例:[运行](https://go.dev/play/p/U_LljFXma14) ```go import ( @@ -1853,7 +1855,7 @@ func main() { func IsSorted[T constraints.Ordered](slice []T) bool ``` -示例: +示例:[运行](https://go.dev/play/p/nCE8wPLwSA-) ```go import ( @@ -1887,7 +1889,7 @@ func main() { func IsSortedByKey[T any, K constraints.Ordered](slice []T, iteratee func(item T) K) bool ``` -示例: +示例:[运行](https://go.dev/play/p/tUoGB7DOHI4) ```go import ( @@ -1927,7 +1929,7 @@ func main() { func Sort[T constraints.Ordered](slice []T, sortOrder ...string) ``` -示例: +示例:[运行](https://go.dev/play/p/V9AVjzf_4Fk) ```go import ( @@ -1964,7 +1966,7 @@ func main() { func SortBy[T any](slice []T, less func(a, b T) bool) ``` -示例: +示例:[运行](https://go.dev/play/p/DAhLQSZEumm) ```go import ( @@ -2011,7 +2013,7 @@ func main() { func SortByField(slice any, field string, sortType ...string) error ``` -示例: +示例:[运行](https://go.dev/play/p/fU1prOBP9p1) ```go import ( @@ -2052,7 +2054,7 @@ func main() { func Some[T any](slice []T, predicate func(index int, item T) bool) bool ``` -示例: +示例:[运行](https://go.dev/play/p/4pO9Xf9NDGS) ```go import ( @@ -2086,7 +2088,7 @@ func main() { func StringSlice(slice any) []string ``` -示例: +示例:[运行](https://go.dev/play/p/W0TZDWCPFcI) ```go import ( @@ -2115,7 +2117,7 @@ func main() { func SymmetricDifference[T comparable](slices ...[]T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/1CbOmtgILUU) ```go import ( @@ -2146,7 +2148,7 @@ func main() { func ToSlice[T any](items ...T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/YzbzVq5kscN) ```go import ( @@ -2174,7 +2176,7 @@ func main() { func ToSlicePointer[T any](items ...T) []*T ``` -示例: +示例:[运行](https://go.dev/play/p/gx4tr6_VXSF) ```go import ( @@ -2209,7 +2211,7 @@ func main() { func Unique[T comparable](slice []T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/AXw0R3ZTE6a) ```go import ( @@ -2236,7 +2238,7 @@ func main() { func UniqueBy[T comparable](slice []T, iteratee func(item T) T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/UR323iZLDpv) ```go import ( @@ -2267,7 +2269,7 @@ func main() { func Union[T comparable](slices ...[]T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/hfXV1iRIZOf) ```go import ( @@ -2298,7 +2300,7 @@ func main() { func UnionBy[T any, V comparable](predicate func(item T) V, slices ...[]T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/HGKHfxKQsFi) ```go import ( @@ -2323,7 +2325,7 @@ func main() { ### UpdateAt -

更新索引处的切片元素。 如果index < 0或 index >= len(slice),将返回错误

+

更新索引处的切片元素。 如果index < 0或 index <= len(slice),将返回错误

函数签名: @@ -2331,7 +2333,7 @@ func main() { func UpdateAt[T any](slice []T, index int, value T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/f3mh2KloWVm) ```go import ( @@ -2371,7 +2373,7 @@ func main() { func Without[T comparable](slice []T, items ...T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/bwhEXEypThg) ```go import ( @@ -2399,7 +2401,7 @@ func main() { func KeyBy[T any, U comparable](slice []T, iteratee func(item T) U) map[U]T ``` -示例: +示例:[运行](https://go.dev/play/p/uXod2LWD1Kg) ```go import ( @@ -2429,7 +2431,7 @@ func main() { func Join[T any](s []T, separator string) string ``` -示例: +示例:[运行](https://go.dev/play/p/huKzqwNDD7V) ```go import ( diff --git a/docs/olddocs/random.md b/docs/en/api/packages/random.md similarity index 81% rename from docs/olddocs/random.md rename to docs/en/api/packages/random.md index d4e9e73..8ecb849 100644 --- a/docs/olddocs/random.md +++ b/docs/en/api/packages/random.md @@ -34,6 +34,8 @@ import (
+ + ## Documentation ### RandBytes @@ -46,7 +48,7 @@ import ( func RandBytes(length int) []byte ``` -Example: +Example:[Run](https://go.dev/play/p/EkiLESeXf8d) ```go package main @@ -72,7 +74,7 @@ func main() { func RandInt(min, max int) int ``` -Example: +Example:[Run](https://go.dev/play/p/pXyyAAI5YxD) ```go package main @@ -98,7 +100,7 @@ func main() { func RandString(length int) string ``` -Example: +Example:[Run](https://go.dev/play/p/W2xvRUXA7Mi) ```go package main @@ -124,7 +126,7 @@ func main() { func RandUpper(length int) string ``` -Example: +Example:[Run](https://go.dev/play/p/29QfOh0DVuh) ```go package main @@ -150,7 +152,7 @@ func main() { func RandLower(length int) string ``` -Example: +Example:[Run](https://go.dev/play/p/XJtZ471cmtI) ```go package main @@ -176,7 +178,7 @@ func main() { func RandNumeral(length int) string ``` -Example: +Example:[Run](https://go.dev/play/p/g4JWVpHsJcf) ```go package main @@ -202,7 +204,7 @@ func main() { func RandNumeralOrLetter(length int) string ``` -Example: +Example:[Run](https://go.dev/play/p/19CEQvpx2jD) ```go package main @@ -228,7 +230,7 @@ func main() { func UUIdV4() (string, error) ``` -Example: +Example:[Run](https://go.dev/play/p/_Z9SFmr28ft) ```go package main @@ -258,7 +260,7 @@ func main() { func RandUniqueIntSlice(n, min, max int) []int ``` -Example: +Example:[Run](https://go.dev/play/p/uBkRSOz73Ec) ```go package main diff --git a/docs/olddocs/retry.md b/docs/en/api/packages/retry.md similarity index 88% rename from docs/olddocs/retry.md rename to docs/en/api/packages/retry.md index b6b5641..64be7f6 100644 --- a/docs/olddocs/retry.md +++ b/docs/en/api/packages/retry.md @@ -30,6 +30,8 @@ import (
+ + ## Documentation ### Context @@ -42,7 +44,7 @@ import ( func Context(ctx context.Context) ``` -Example: +Example:[Run](https://go.dev/play/p/xnAOOXv9GkS) ```go import ( @@ -89,7 +91,7 @@ func main() { type RetryFunc func() error ``` -Example: +Example:[Run](https://go.dev/play/p/nk2XRmagfVF) ```go package main @@ -135,7 +137,7 @@ func main() { func RetryTimes(n uint) ``` -Example: +Example:[Run](https://go.dev/play/p/ssfVeU2SwLO) ```go package main @@ -178,7 +180,7 @@ func main() { func RetryDuration(d time.Duration) ``` -Example: +Example:[Run](https://go.dev/play/p/nk2XRmagfVF) ```go package main @@ -224,7 +226,7 @@ func main() { func Retry(retryFunc RetryFunc, opts ...Option) error ``` -Example: +Example:[Run](https://go.dev/play/p/nk2XRmagfVF) ```go package main diff --git a/docs/olddocs/slice.md b/docs/en/api/packages/slice.md similarity index 86% rename from docs/olddocs/slice.md rename to docs/en/api/packages/slice.md index dbfb768..4a31f44 100644 --- a/docs/olddocs/slice.md +++ b/docs/en/api/packages/slice.md @@ -94,6 +94,8 @@ import (
+ + ## Documentation ### AppendIfAbsent @@ -106,7 +108,7 @@ import ( func AppendIfAbsent[T comparable](slice []T, item T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/xnAOOXv9GkS) ```go import ( @@ -137,7 +139,7 @@ func main() { func Contain[T comparable](slice []T, target T) bool ``` -Example: +Example:[Run](https://go.dev/play/p/xnAOOXv9GkS) ```go import ( @@ -168,7 +170,7 @@ func main() { func ContainBy[T any](slice []T, predicate func(item T) bool) bool ``` -Example: +Example:[Run](https://go.dev/play/p/xnAOOXv9GkS) ```go import ( @@ -213,7 +215,7 @@ func main() { func ContainSubSlice[T comparable](slice, subSlice []T) bool ``` -Example: +Example:[Run](https://go.dev/play/p/bcuQ3UT6Sev) ```go import ( @@ -244,7 +246,7 @@ func main() { func Chunk[T any](slice []T, size int) [][]T ``` -Example: +Example:[Run](https://go.dev/play/p/b4Pou5j2L_C) ```go import ( @@ -286,7 +288,7 @@ func main() { func Compact[T comparable](slice []T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/pO5AnxEr3TK) ```go import ( @@ -323,7 +325,7 @@ func main() { func Concat[T any](slice []T, slices ...[]T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/gPt-q7zr5mk) ```go import ( @@ -354,7 +356,7 @@ func main() { func Count[T comparable](slice []T, item T) int ``` -Example: +Example:[Run](https://go.dev/play/p/Mj4oiEnQvRJ) ```go import ( @@ -387,7 +389,7 @@ func main() { func CountBy[T any](slice []T, predicate func(index int, item T) bool) int ``` -Example: +Example:[Run](https://go.dev/play/p/tHOccTMDZCC) ```go import ( @@ -421,7 +423,7 @@ func main() { func Difference[T comparable](slice, comparedSlice []T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/VXvadzLzhDa) ```go import ( @@ -452,7 +454,7 @@ func main() { func DifferenceBy[T comparable](slice []T, comparedSlice []T, iteratee func(index int, item T) T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/DiivgwM5OnC) ```go import ( @@ -487,7 +489,7 @@ func main() { func DifferenceWith[T any](slice []T, comparedSlice []T, comparator func(value, otherValue T) bool) []T ``` -Example: +Example:[Run](https://go.dev/play/p/v2U2deugKuV) ```go import ( @@ -522,7 +524,7 @@ func main() { func DeleteAt[T any](slice []T, start int, end ...int) ``` -Example: +Example:[Run](https://go.dev/play/p/pJ-d6MUWcvK) ```go import ( @@ -556,7 +558,7 @@ func main() { func Drop[T any](slice []T, n int) []T ``` -Example: +Example:[Run](https://go.dev/play/p/jnPO2yQsT8H) ```go import ( @@ -593,7 +595,7 @@ func main() { func DropRight[T any](slice []T, n int) []T ``` -Example: +Example:[Run](https://go.dev/play/p/8bcXvywZezG) ```go import ( @@ -630,7 +632,7 @@ func main() { func DropWhile[T any](slice []T, predicate func(item T) bool) []T ``` -Example: +Example:[Run](https://go.dev/play/p/4rt252UV_qs) ```go import ( @@ -670,7 +672,7 @@ func main() { func DropRightWhile[T any](slice []T, predicate func(item T) bool) []T ``` -Example: +Example:[Run](https://go.dev/play/p/6wyK3zMY56e) ```go import ( @@ -712,7 +714,7 @@ func main() { func Equal[T comparable](slice1, slice2 []T) bool ``` -Example: +Example:[Run](https://go.dev/play/p/WcRQJ37ifPa) ```go import ( @@ -747,7 +749,7 @@ func main() { func EqualWith[T, U any](slice1 []T, slice2 []U, comparator func(T, U) bool) bool ``` -Example: +Example:[Run](https://go.dev/play/p/b9iygtgsHI1) ```go import ( @@ -782,7 +784,7 @@ func main() { func Every[T any](slice []T, predicate func(index int, item T) bool) bool ``` -Example: +Example:[Run](https://go.dev/play/p/R8U6Sl-j8cD) ```go import ( @@ -816,7 +818,7 @@ func main() { func Filter[T any](slice []T, predicate func(index int, item T) bool) []T ``` -Example: +Example:[Run](https://go.dev/play/p/SdPna-7qK4T) ```go import ( @@ -850,7 +852,7 @@ func main() { func Find[T any](slice []T, predicate func(index int, item T) bool) (*T, bool) ``` -Example: +Example:[Run](https://go.dev/play/p/CBKeBoHVLgq) ```go import ( @@ -886,7 +888,7 @@ func main() { func FindBy[T any](slice []T, predicate func(index int, item T) bool) (v T, ok bool) ``` -Example: +Example:[Run](https://go.dev/play/p/n1lysBYl-GB) ```go import ( @@ -922,7 +924,7 @@ func main() { func FindLast[T any](slice []T, predicate func(index int, item T) bool) (*T, bool) ``` -Example: +Example:[Run](https://go.dev/play/p/FFDPV_j7URd) ```go import ( @@ -958,7 +960,7 @@ func main() { func FindLastBy[T any](slice []T, predicate func(index int, item T) bool) (v T, ok bool) ``` -Example: +Example:[Run](https://go.dev/play/p/8iqomzyCl_s) ```go import ( @@ -994,7 +996,7 @@ func main() { func Flatten(slice any) any ``` -Example: +Example:[Run](https://go.dev/play/p/hYa3cBEevtm) ```go import ( @@ -1024,7 +1026,7 @@ func main() { func FlattenDeep(slice any) any ``` -Example: +Example:[Run](https://go.dev/play/p/yjYNHPyCFaF) ```go import ( @@ -1054,7 +1056,7 @@ func main() { func ForEach[T any](slice []T, iteratee func(index int, item T)) ``` -Example: +Example:[Run](https://go.dev/play/p/DrPaa4YsHRF) ```go import ( @@ -1089,7 +1091,7 @@ func main() { func ForEachWithBreak[T any](slice []T, iteratee func(index int, item T) bool) ``` -Example: +Example:[Run](https://go.dev/play/p/qScs39f3D9W) ```go import ( @@ -1127,7 +1129,7 @@ func main() { func GroupBy[T any](slice []T, groupFn func(index int, item T) bool) ([]T, []T) ``` -Example: +Example:[Run](https://go.dev/play/p/QVkPxzPR0iA) ```go import ( @@ -1163,7 +1165,7 @@ func main() { func GroupWith[T any, U comparable](slice []T, iteratee func(T) U) map[U][]T ``` -Example: +Example:[Run](https://go.dev/play/p/ApCvMNTLO8a) ```go import ( @@ -1197,7 +1199,7 @@ func main() { func IntSlice(slice any) []int ``` -Example: +Example:[Run](https://go.dev/play/p/UQDj-on9TGN) ```go import ( @@ -1226,7 +1228,7 @@ func main() { func InterfaceSlice(slice any) []any ``` -Example: +Example:[Run](https://go.dev/play/p/FdQXF0Vvqs-) ```go import ( @@ -1255,7 +1257,7 @@ func main() { func Intersection[T comparable](slices ...[]T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/anJXfB5wq_t) ```go import ( @@ -1286,7 +1288,7 @@ func main() { func InsertAt[T any](slice []T, index int, value any) []T ``` -Example: +Example:[Run](https://go.dev/play/p/hMLNxPEGJVE) ```go import ( @@ -1326,7 +1328,7 @@ func main() { func IndexOf[T comparable](slice []T, item T) int ``` -Example: +Example:[Run](https://go.dev/play/p/MRN1f0FpABb) ```go import ( @@ -1359,7 +1361,7 @@ func main() { func LastIndexOf[T comparable](slice []T, item T) int ``` -Example: +Example:[Run](https://go.dev/play/p/DokM4cf1IKH) ```go import ( @@ -1392,7 +1394,7 @@ func main() { func Map[T any, U any](slice []T, iteratee func(index int, item T) U) []U ``` -Example: +Example:[Run](https://go.dev/play/p/biaTefqPquw) ```go import ( @@ -1426,7 +1428,7 @@ func main() { func FilterMap[T any, U any](slice []T, iteratee func(index int, item T) (U, bool)) []U ``` -Example: +Example:[Run](https://go.dev/play/p/J94SZ_9MiIe) ```go import ( @@ -1463,7 +1465,7 @@ func main() { func FlatMap[T any, U any](slice []T, iteratee func(index int, item T) []U) []U ``` -Example: +Example:[Run](https://go.dev/play/p/_QARWlWs1N_F) ```go import ( @@ -1496,7 +1498,7 @@ func main() { func Merge[T any](slices ...[]T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/lbjFp784r9N) ```go import ( @@ -1527,7 +1529,7 @@ func main() { func Reverse[T any](slice []T) ``` -Example: +Example:[Run](https://go.dev/play/p/8uI8f1lwNrQ) ```go import ( @@ -1557,7 +1559,7 @@ func main() { func Reduce[T any](slice []T, iteratee func(index int, item1, item2 T) T, initial T) T ``` -Example: +Example:[Run](https://go.dev/play/p/_RfXJJWIsIm) ```go import ( @@ -1591,7 +1593,7 @@ func main() { func ReduceBy[T any, U any](slice []T, initial U, reducer func(index int, item T, agg U) U) U ``` -Example: +Example:[Run](https://go.dev/play/p/YKDpLi7gtee) ```go import ( @@ -1627,7 +1629,7 @@ func main() { func ReduceRight[T any, U any](slice []T, initial U, reducer func(index int, item T, agg U) U) U ``` -Example: +Example:[Run](https://go.dev/play/p/qT9dZC03A1K) ```go import ( @@ -1657,7 +1659,7 @@ func main() { func Replace[T comparable](slice []T, old T, new T, n int) []T ``` -Example: +Example:[Run](https://go.dev/play/p/P5mZp7IhOFo) ```go import ( @@ -1699,7 +1701,7 @@ func main() { func ReplaceAll[T comparable](slice []T, old T, new T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/CzqXMsuYUrx) ```go import ( @@ -1727,7 +1729,7 @@ func main() { func Repeat[T any](item T, n int) []T ``` -Example: +Example:[Run](https://go.dev/play/p/1CbOmtgILUU) ```go import ( @@ -1755,7 +1757,7 @@ func main() { func Shuffle[T any](slice []T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/YHvhnWGU3Ge) ```go import ( @@ -1784,7 +1786,7 @@ func main() { func IsAscending[T constraints.Ordered](slice []T) bool ``` -Example: +Example:[Run](https://go.dev/play/p/9CtsFjet4SH) ```go import ( @@ -1818,7 +1820,7 @@ func main() { func IsDescending[T constraints.Ordered](slice []T) bool ``` -Example: +Example:[Run](https://go.dev/play/p/U_LljFXma14) ```go import ( @@ -1852,7 +1854,7 @@ func main() { func IsSorted[T constraints.Ordered](slice []T) bool ``` -Example: +Example:[Run](https://go.dev/play/p/nCE8wPLwSA-) ```go import ( @@ -1886,7 +1888,7 @@ func main() { func IsSortedByKey[T any, K constraints.Ordered](slice []T, iteratee func(item T) K) bool ``` -Example: +Example:[Run](https://go.dev/play/p/tUoGB7DOHI4) ```go import ( @@ -1927,7 +1929,7 @@ func main() { func Sort[T constraints.Ordered](slice []T, sortOrder ...string) ``` -Example: +Example:[Run](https://go.dev/play/p/V9AVjzf_4Fk) ```go import ( @@ -1964,7 +1966,7 @@ func main() { func SortBy[T any](slice []T, less func(a, b T) bool) ``` -Example: +Example:[Run](https://go.dev/play/p/DAhLQSZEumm) ```go import ( @@ -2011,7 +2013,7 @@ func main() { func SortByField(slice any, field string, sortType ...string) error ``` -Example: +Example:[Run](https://go.dev/play/p/fU1prOBP9p1) ```go import ( @@ -2052,7 +2054,7 @@ func main() { func Some[T any](slice []T, predicate func(index int, item T) bool) bool ``` -Example: +Example:[Run](https://go.dev/play/p/4pO9Xf9NDGS) ```go import ( @@ -2086,7 +2088,7 @@ func main() { func StringSlice(slice any) []string ``` -Example: +Example:[Run](https://go.dev/play/p/W0TZDWCPFcI) ```go import ( @@ -2115,7 +2117,7 @@ func main() { func SymmetricDifference[T comparable](slices ...[]T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/1CbOmtgILUU) ```go import ( @@ -2146,7 +2148,7 @@ func main() { func ToSlice[T any](items ...T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/YzbzVq5kscN) ```go import ( @@ -2174,7 +2176,7 @@ func main() { func ToSlicePointer[T any](items ...T) []*T ``` -Example: +Example:[Run](https://go.dev/play/p/gx4tr6_VXSF) ```go import ( @@ -2209,7 +2211,7 @@ func main() { func Unique[T comparable](slice []T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/AXw0R3ZTE6a) ```go import ( @@ -2236,7 +2238,7 @@ func main() { func UniqueBy[T comparable](slice []T, iteratee func(item T) T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/UR323iZLDpv) ```go import ( @@ -2267,7 +2269,7 @@ func main() { func Union[T comparable](slices ...[]T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/hfXV1iRIZOf) ```go import ( @@ -2298,7 +2300,7 @@ func main() { func UnionBy[T any, V comparable](predicate func(item T) V, slices ...[]T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/HGKHfxKQsFi) ```go import ( @@ -2323,7 +2325,7 @@ func main() { ### UpdateAt -

Update the slice element at index. if param index < 0 or index >= len(slice), will return error.

+

Update the slice element at index. if param index < 0 or index <= len(slice), will return error.

Signature: @@ -2331,7 +2333,7 @@ func main() { func UpdateAt[T any](slice []T, index int, value T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/f3mh2KloWVm) ```go import ( @@ -2371,7 +2373,7 @@ func main() { func Without[T comparable](slice []T, items ...T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/bwhEXEypThg) ```go import ( @@ -2399,7 +2401,7 @@ func main() { func KeyBy[T any, U comparable](slice []T, iteratee func(item T) U) map[U]T ``` -Example: +Example:[Run](https://go.dev/play/p/uXod2LWD1Kg) ```go import ( @@ -2429,7 +2431,7 @@ func main() { func Join[T any](s []T, separator string) string ``` -Example: +Example:[Run](https://go.dev/play/p/huKzqwNDD7V) ```go import (