diff --git a/docs/.vitepress/en.ts b/docs/.vitepress/en.ts index 98d5f40..47af998 100644 --- a/docs/.vitepress/en.ts +++ b/docs/.vitepress/en.ts @@ -90,6 +90,10 @@ export const enConfig: LocaleSpecificConfig = { { text: 'fileutil', link: '/en/api/packages/fileutil' }, { text: 'formatter', link: '/en/api/packages/formatter' }, { text: 'function', link: '/en/api/packages/function' }, + { text: 'mathutil', link: '/en/api/packages/mathutil' }, + { text: 'maputil', link: '/en/api/packages/maputil' }, + { text: 'netutil', link: '/en/api/packages/netutil' }, + { text: 'pointer', link: '/en/api/packages/pointer' }, ], }, ], diff --git a/docs/.vitepress/zh.ts b/docs/.vitepress/zh.ts index 25b40eb..4750e9c 100644 --- a/docs/.vitepress/zh.ts +++ b/docs/.vitepress/zh.ts @@ -86,7 +86,10 @@ export const zhConfig: LocaleSpecificConfig = { collapsed: true, items: [ { text: '线性表', link: '/api/packages/datastructure/list' }, - { text: '线性表(线程安全)', link: '/api/packages/datastructure/copyonwritelist' }, + { + text: '线性表(线程安全)', + link: '/api/packages/datastructure/copyonwritelist', + }, { text: '链表', link: '/api/packages/datastructure/link' }, { text: '栈', link: '/api/packages/datastructure/stack' }, { text: '队列', link: '/api/packages/datastructure/queue' }, @@ -100,6 +103,10 @@ export const zhConfig: LocaleSpecificConfig = { { text: '文件', link: '/api/packages/fileutil' }, { text: '格式化工具', link: '/api/packages/formatter' }, { text: '函数', link: '/api/packages/function' }, + { text: '数学工具', link: '/api/packages/mathutil' }, + { text: 'Map', link: '/api/packages/maputil' }, + { text: '网络', link: '/api/packages/netutil' }, + { text: '指针', link: '/api/packages/pointer' }, ], }, ], diff --git a/docs/olddocs/maputil_zh-CN.md b/docs/api/packages/maputil.md similarity index 88% rename from docs/olddocs/maputil_zh-CN.md rename to docs/api/packages/maputil.md index d814538..5fdd8a4 100644 --- a/docs/olddocs/maputil_zh-CN.md +++ b/docs/api/packages/maputil.md @@ -53,9 +53,10 @@ import ( - [ConcurrentMap_Has](#ConcurrentMap_Has) - [ConcurrentMap_Range](#ConcurrentMap_Range) -
+ + ## API 文档: ### MapTo @@ -68,7 +69,7 @@ import ( func MapTo(src any, dst any) error ``` -示例: +示例:[运行](https://go.dev/play/p/4K7KBEPgS5M) ```go package main @@ -125,7 +126,7 @@ func main() { func ForEach[K comparable, V any](m map[K]V, iteratee func(key K, value V)) ``` -示例: +示例:[运行](https://go.dev/play/p/OaThj6iNVXK) ```go package main @@ -166,7 +167,7 @@ func main() { func Filter[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) map[K]V ``` -示例: +示例:[运行](https://go.dev/play/p/fSvF3wxuNG7) ```go package main @@ -211,7 +212,7 @@ func main() { func FilterByKeys[K comparable, V any](m map[K]V, keys []K) map[K]V ``` -示例: +示例:[运行](https://go.dev/play/p/7ov6BJHbVqh) ```go package main @@ -249,7 +250,7 @@ func main() { func FilterByValues[K comparable, V comparable](m map[K]V, values []V) map[K]V ``` -示例: +示例:[运行](https://go.dev/play/p/P3-9MdcXegR) ```go package main @@ -287,7 +288,7 @@ func main() { func OmitBy[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) map[K]V ``` -示例: +示例:[运行](https://go.dev/play/p/YJM4Hj5hNwm) ```go package main @@ -328,7 +329,7 @@ func main() { func OmitByKeys[K comparable, V any](m map[K]V, keys []K) map[K]V ``` -示例: +示例:[运行](https://go.dev/play/p/jXGrWDBfSRp) ```go package main @@ -366,7 +367,7 @@ func main() { func OmitByValues[K comparable, V comparable](m map[K]V, values []V) map[K]V ``` -示例: +示例:[运行](https://go.dev/play/p/XB7Y10uw20_U) ```go package main @@ -404,7 +405,7 @@ func main() { func Intersect[K comparable, V any](maps ...map[K]V) map[K]V ``` -示例: +示例:[运行](https://go.dev/play/p/Zld0oj3sjcC) ```go package main @@ -459,7 +460,7 @@ func main() { func Keys[K comparable, V any](m map[K]V) []K ``` -示例: +示例:[运行](https://go.dev/play/p/xNB5bTb97Wd) ```go package main @@ -498,7 +499,7 @@ func main() { func Merge[K comparable, V any](maps ...map[K]V) map[K]V ``` -示例: +示例:[运行](https://go.dev/play/p/H95LENF1uB-) ```go package main @@ -537,7 +538,7 @@ func main() { func Minus[K comparable, V any](mapA, mapB map[K]V) map[K]V ``` -示例: +示例:[运行](https://go.dev/play/p/3u5U9K7YZ9m) ```go package main @@ -579,7 +580,7 @@ func main() { func Values[K comparable, V any](m map[K]V) []V ``` -示例: +示例:[运行](https://go.dev/play/p/CBKdUc5FTW6) ```go package main @@ -616,7 +617,7 @@ func main() { func KeysBy[K comparable, V any, T any](m map[K]V, mapper func(item K) T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/hI371iB8Up8) ```go package main @@ -657,7 +658,7 @@ func main() { func ValuesBy[K comparable, V any, T any](m map[K]V, mapper func(item V) T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/sg9-oRidh8f) ```go package main @@ -706,7 +707,7 @@ func main() { func MapKeys[K comparable, V any, T comparable](m map[K]V, iteratee func(key K, value V) T) map[T]V ``` -示例: +示例:[运行](https://go.dev/play/p/8scDxWeBDKd) ```go package main @@ -745,7 +746,7 @@ func main() { func MapValues[K comparable, V any, T any](m map[K]V, iteratee func(key K, value V) T) map[K]T ``` -示例: +示例:[运行](https://go.dev/play/p/g92aY3fc7Iw) ```go package main @@ -788,7 +789,7 @@ type Entry[K comparable, V any] struct { func Entries[K comparable, V any](m map[K]V) []Entry[K, V] ``` -示例: +示例:[运行](https://go.dev/play/p/Ltb11LNcElY) ```go package main @@ -833,7 +834,7 @@ type Entry[K comparable, V any] struct { func FromEntries[K comparable, V any](entries []Entry[K, V]) map[K]V ``` -示例: +示例:[运行](https://go.dev/play/p/C8L4ul9TVwf) ```go package main @@ -867,7 +868,7 @@ func main() { func Transform[K1 comparable, V1 any, K2 comparable, V2 any](m map[K1]V1, iteratee func(key K1, value V1) (K2, V2)) map[K2]V2 ``` -示例: +示例:[运行](https://go.dev/play/p/P6ovfToM3zj) ```go package main @@ -906,7 +907,7 @@ func main() { func IsDisjoint[K comparable, V any](mapA, mapB map[K]V) bool ``` -示例: +示例:[运行](https://go.dev/play/p/N9qgYg_Ho6f) ```go package main @@ -961,7 +962,7 @@ if haskey { func HasKey[K comparable, V any](m map[K]V, key K) bool ``` -示例: +示例:[运行](https://go.dev/play/p/isZZHOsDhFc) ```go package main @@ -1000,7 +1001,7 @@ func main() { func NewConcurrentMap[K comparable, V any](shardCount int) *ConcurrentMap[K, V] ``` -实例: +示例:[运行](https://go.dev/play/p/3PenTPETJT0) ```go package main @@ -1026,7 +1027,7 @@ func main() { func (cm *ConcurrentMap[K, V]) Set(key K, value V) ``` -实例: +示例:[运行](https://go.dev/play/p/3PenTPETJT0) ```go package main @@ -1080,7 +1081,7 @@ func main() { func (cm *ConcurrentMap[K, V]) Get(key K) (V, bool) ``` -实例: +示例:[运行](https://go.dev/play/p/3PenTPETJT0) ```go package main @@ -1134,7 +1135,7 @@ func main() { func (cm *ConcurrentMap[K, V]) GetOrSet(key K, value V) (actual V, ok bool) ``` -实例: +示例:[运行](https://go.dev/play/p/aDcDApOK01a) ```go package main @@ -1178,7 +1179,7 @@ func main() { func (cm *ConcurrentMap[K, V]) Delete(key K) ``` -实例: +示例:[运行](https://go.dev/play/p/uTIJZYhpVMS) ```go package main @@ -1214,7 +1215,6 @@ func main() { } ``` - ### ConcurrentMap_GetAndDelete

获取key,然后删除。

@@ -1225,7 +1225,7 @@ func main() { func (cm *ConcurrentMap[K, V]) GetAndDelete(key K) (actual V, ok bool) ``` -实例: +示例:[运行](https://go.dev/play/p/ZyxeIXSZUiM) ```go package main @@ -1266,7 +1266,6 @@ func main() { } ``` - ### ConcurrentMap_Has

验证是否包含key。

@@ -1277,7 +1276,7 @@ func main() { func (cm *ConcurrentMap[K, V]) Has(key K) bool ``` -实例: +示例:[运行](https://go.dev/play/p/C8L4ul9TVwf) ```go package main @@ -1315,7 +1314,6 @@ func main() { } ``` - ### ConcurrentMap_Range

为map中每个键和值顺序调用迭代器。 如果iterator返回false,则停止迭代。

@@ -1326,7 +1324,7 @@ func main() { func (cm *ConcurrentMap[K, V]) Range(iterator func(key K, value V) bool) ``` -实例: +示例:[运行](https://go.dev/play/p/iqcy7P8P0Pr) ```go package main @@ -1357,4 +1355,3 @@ func main() { }) } ``` - diff --git a/docs/olddocs/mathutil_zh-CN.md b/docs/api/packages/mathutil.md similarity index 86% rename from docs/olddocs/mathutil_zh-CN.md rename to docs/api/packages/mathutil.md index 45c64c6..d3bf8d3 100644 --- a/docs/olddocs/mathutil_zh-CN.md +++ b/docs/api/packages/mathutil.md @@ -50,7 +50,9 @@ import (
-## Documentation + + +## 文档 ### Average @@ -97,7 +99,7 @@ func main() { func Exponent(x, n int64) int64 ``` -示例: +示例:[运行](https://go.dev/play/p/Vv7LBwER-pz) ```go package main @@ -133,7 +135,7 @@ func main() { func Fibonacci(first, second, n int) int ``` -示例: +示例:[运行](https://go.dev/play/p/IscseUNMuUc) ```go package main @@ -169,7 +171,7 @@ func main() { func Factorial(x uint) uint ``` -示例: +示例:[运行](https://go.dev/play/p/tt6LdOK67Nx) ```go package main @@ -205,7 +207,7 @@ func main() { func Max[T constraints.Integer | constraints.Float](numbers ...T) T ``` -示例: +示例:[运行](https://go.dev/play/p/cN8DHI0rTkH) ```go package main @@ -238,7 +240,7 @@ func main() { func MaxBy[T any](slice []T, comparator func(T, T) bool) T ``` -示例: +示例:[运行](https://go.dev/play/p/pbe2MT-7DV2) ```go package main @@ -282,7 +284,7 @@ func main() { func Min[T constraints.Integer | constraints.Float](numbers ...T) T ``` -示例: +示例:[运行](https://go.dev/play/p/pbe2MT-7DV2) ```go package main @@ -315,7 +317,7 @@ func main() { func MinBy[T any](slice []T, comparator func(T, T) bool) T ``` -示例: +示例:[运行](https://go.dev/play/p/N9qgYg_Ho6f) ```go package main @@ -359,7 +361,7 @@ func main() { func Percent(val, total float64, n int) float64 ``` -示例: +示例:[运行](https://go.dev/play/p/s0NdFCtwuyd) ```go package main @@ -395,7 +397,7 @@ func main() { func RoundToFloat(x float64, n int) float64 ``` -示例: +示例:[运行](https://go.dev/play/p/ghyb528JRJL) ```go package main @@ -431,7 +433,7 @@ func main() { func RoundToString(x float64, n int) string ``` -示例: +示例:[运行](https://go.dev/play/p/kZwpBRAcllO) ```go package main @@ -467,7 +469,7 @@ func main() { func TruncRound(x float64, n int) float64 ``` -示例: +示例:[运行](https://go.dev/play/p/aumarSHIGzP) ```go package main @@ -503,7 +505,7 @@ func main() { func Range[T constraints.Integer | constraints.Float](start T, count int) []T ``` -示例: +示例:[运行](https://go.dev/play/p/9ke2opxa8ZP) ```go package main @@ -542,7 +544,7 @@ func main() { func RangeWithStep[T constraints.Integer | constraints.Float](start, end, step T) []T ``` -示例: +示例:[运行](https://go.dev/play/p/akLWz0EqOSM) ```go package main @@ -581,7 +583,7 @@ func main() { func AngleToRadian(angle float64) float64 ``` -示例: +示例:[运行](https://go.dev/play/p/CIvlICqrHql) ```go package main @@ -617,7 +619,7 @@ func main() { func RadianToAngle(radian float64) float64 ``` -示例: +示例:[运行](https://go.dev/play/p/dQtmOTUOMgi) ```go package main @@ -653,7 +655,7 @@ func main() { func PointDistance(x1, y1, x2, y2 float64) float64 ``` -示例: +示例:[运行](https://go.dev/play/p/RrG4JIaziM8) ```go package main @@ -683,7 +685,7 @@ func main() { func IsPrime(n int) bool ``` -示例: +示例:[运行](https://go.dev/play/p/Rdd8UTHZJ7u) ```go package main @@ -722,7 +724,7 @@ func main() { func GCD[T constraints.Integer](integers ...T) T ``` -示例: +示例:[运行](https://go.dev/play/p/CiEceLSoAKB) ```go package main @@ -764,7 +766,7 @@ func main() { func LCM[T constraints.Integer](integers ...T) T ``` -示例: +示例:[运行](https://go.dev/play/p/EjcZxfY7G_g) ```go package main @@ -800,7 +802,7 @@ func main() { func Cos(radian float64, precision ...int) float64 ``` -示例: +示例:[运行](https://go.dev/play/p/Sm89LoIfvFq) ```go package main @@ -842,7 +844,7 @@ func main() { func Sin(radian float64, precision ...int) float64 ``` -示例: +示例:[运行](https://go.dev/play/p/TWMQlMywDsP) ```go package main @@ -884,7 +886,7 @@ func main() { func Log(n, base float64) float64 ``` -示例: +示例:[运行](https://go.dev/play/p/_d4bi8oyhat) ```go package main @@ -920,7 +922,7 @@ func main() { func Sum[T constraints.Integer | constraints.Float](numbers ...T) T ``` -示例: +示例:[运行](https://go.dev/play/p/1To2ImAMJA7) ```go package main @@ -953,7 +955,7 @@ func main() { func Abs[T constraints.Integer | constraints.Float](x T) T ``` -示例: +示例:[运行](https://go.dev/play/p/fsyBh1Os-1d) ```go package main diff --git a/docs/olddocs/netutil_zh-CN.md b/docs/api/packages/netutil.md similarity index 92% rename from docs/olddocs/netutil_zh-CN.md rename to docs/api/packages/netutil.md index 07a5d0a..7728681 100644 --- a/docs/olddocs/netutil_zh-CN.md +++ b/docs/api/packages/netutil.md @@ -51,6 +51,8 @@ import (
+ + ## 文档 ### ConvertMapToQueryString @@ -63,7 +65,7 @@ import ( func ConvertMapToQueryString(param map[string]any) string ``` -示例: +示例:[运行](https://go.dev/play/p/jnNt_qoSnRi) ```go package main @@ -98,7 +100,7 @@ func main() { func EncodeUrl(urlStr string) (string, error) ``` -示例: +示例:[运行](https://go.dev/play/p/bsZ6BRC4uKI) ```go package main @@ -133,7 +135,7 @@ func main() { func GetInternalIp() string ``` -示例: +示例:[运行](https://go.dev/play/p/fxnna_LLD9u) ```go package main @@ -165,7 +167,7 @@ func main() { func GetIps() []string ``` -示例: +示例:[运行](https://go.dev/play/p/NUFfcEmukx1) ```go package main @@ -195,7 +197,7 @@ func main() { func GetMacAddrs() []string { ``` -示例: +示例:[运行](https://go.dev/play/p/Rq9UUBS_Xp1) ```go package main @@ -239,7 +241,7 @@ type PublicIpInfo struct { } ``` -示例: +示例:[运行](https://go.dev/play/p/YDxIfozsRHR) ```go package main @@ -269,7 +271,7 @@ func main() { func GetRequestPublicIp(req *http.Request) string ``` -示例: +示例:[运行](https://go.dev/play/p/kxU-YDc_eBo) ```go package main @@ -307,7 +309,7 @@ func main() { func IsPublicIP(IP net.IP) bool ``` -示例: +示例:[运行](https://go.dev/play/p/nmktSQpJZnn) ```go package main @@ -344,7 +346,7 @@ func main() { func IsInternalIP(IP net.IP) bool ``` -示例: +示例:[运行](https://go.dev/play/p/sYGhXbgO4Cb) ```go package main @@ -388,7 +390,7 @@ type HttpRequest struct { } ``` -示例: +示例:[运行](https://go.dev/play/p/jUSgynekH7G) ```go package main @@ -445,7 +447,7 @@ func NewHttpClientWithConfig(config *HttpClientConfig) *HttpClient ``` -示例: +示例:[运行](https://go.dev/play/p/jUSgynekH7G) ```go package main @@ -476,7 +478,7 @@ func main() { func (client *HttpClient) SendRequest(request *HttpRequest) (*http.Response, error) ``` -示例: +示例:[运行](https://go.dev/play/p/jUSgynekH7G) ```go package main @@ -530,7 +532,7 @@ func main() { func (client *HttpClient) DecodeResponse(resp *http.Response, target any) error ``` -示例: +示例:[运行](https://go.dev/play/p/jUSgynekH7G) ```go package main @@ -584,7 +586,7 @@ func main() { func StructToUrlValues(targetStruct any) url.Values ``` -示例: +示例:[运行](https://go.dev/play/p/pFqMkM40w9z) ```go package main @@ -966,7 +968,7 @@ func main() { func IsPingConnected(host string) bool ``` -示例: +示例:[运行](https://go.dev/play/p/q8OzTijsA87) ```go package main @@ -999,7 +1001,7 @@ func main() { func IsTelnetConnected(host string, port string) bool ``` -示例: +示例:[运行](https://go.dev/play/p/yiLCGtQv_ZG) ```go package main diff --git a/docs/olddocs/pointer_zh-CN.md b/docs/api/packages/pointer.md similarity index 85% rename from docs/olddocs/pointer_zh-CN.md rename to docs/api/packages/pointer.md index 9362203..747beef 100644 --- a/docs/olddocs/pointer_zh-CN.md +++ b/docs/api/packages/pointer.md @@ -30,6 +30,8 @@ import (
+ + ## 文档 ### Of @@ -42,7 +44,7 @@ import ( func Of[T any](v T) *T ``` -示例: +示例:[运行](https://go.dev/play/p/HFd70x4DrMj) ```go package main @@ -75,7 +77,7 @@ func main() { func Unwrap[T any](p *T) T ``` -示例: +示例:[运行](https://go.dev/play/p/cgeu3g7cjWb) ```go package main @@ -111,7 +113,7 @@ func main() { func ExtractPointer(value any) any ``` -示例: +示例:[运行](https://go.dev/play/p/D7HFjeWU2ZP) ```go package main @@ -146,7 +148,7 @@ func main() { UnwarpOr[T any](p *T, fallback T) T ``` -示例: +示例:[运行](https://go.dev/play/p/mmNaLC38W8C) ```go package main @@ -191,7 +193,7 @@ func main() { UnwarpOrDefault[T any](p *T) T ``` -示例: +示例:[运行](https://go.dev/play/p/ZnGIHf8_o4E) ```go package main diff --git a/docs/olddocs/maputil.md b/docs/en/api/packages/maputil.md similarity index 88% rename from docs/olddocs/maputil.md rename to docs/en/api/packages/maputil.md index 5e9b79e..cd48dd4 100644 --- a/docs/olddocs/maputil.md +++ b/docs/en/api/packages/maputil.md @@ -55,6 +55,8 @@ import (
+ + ## Documentation ### MapTo @@ -67,7 +69,7 @@ import ( func MapTo(src any, dst any) error ``` -Example: +Example:[Run](https://go.dev/play/p/4K7KBEPgS5M) ```go package main @@ -124,7 +126,7 @@ func main() { func ForEach[K comparable, V any](m map[K]V, iteratee func(key K, value V)) ``` -Example: +Example:[Run](https://go.dev/play/p/OaThj6iNVXK) ```go package main @@ -165,7 +167,7 @@ func main() { func Filter[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) map[K]V ``` -Example: +Example:[Run](https://go.dev/play/p/fSvF3wxuNG7) ```go package main @@ -210,7 +212,7 @@ func main() { func FilterByKeys[K comparable, V any](m map[K]V, keys []K) map[K]V ``` -Example: +Example:[Run](https://go.dev/play/p/7ov6BJHbVqh) ```go package main @@ -248,7 +250,7 @@ func main() { func FilterByValues[K comparable, V comparable](m map[K]V, values []V) map[K]V ``` -Example: +Example:[Run](https://go.dev/play/p/P3-9MdcXegR) ```go package main @@ -286,7 +288,7 @@ func main() { func OmitBy[K comparable, V any](m map[K]V, predicate func(key K, value V) bool) map[K]V ``` -Example: +Example:[Run](https://go.dev/play/p/YJM4Hj5hNwm) ```go package main @@ -327,7 +329,7 @@ func main() { func OmitByKeys[K comparable, V any](m map[K]V, keys []K) map[K]V ``` -Example: +Example:[Run](https://go.dev/play/p/jXGrWDBfSRp) ```go package main @@ -365,7 +367,7 @@ func main() { func OmitByValues[K comparable, V comparable](m map[K]V, values []V) map[K]V ``` -Example: +Example:[Run](https://go.dev/play/p/XB7Y10uw20_U) ```go package main @@ -403,7 +405,7 @@ func main() { func Intersect[K comparable, V any](maps ...map[K]V) map[K]V ``` -Example: +Example:[Run](https://go.dev/play/p/Zld0oj3sjcC) ```go package main @@ -458,7 +460,7 @@ func main() { func Keys[K comparable, V any](m map[K]V) []K ``` -Example: +Example:[Run](https://go.dev/play/p/xNB5bTb97Wd) ```go package main @@ -498,7 +500,7 @@ func main() { func Merge[K comparable, V any](maps ...map[K]V) map[K]V ``` -Example: +Example:[Run](https://go.dev/play/p/H95LENF1uB-) ```go package main @@ -537,7 +539,7 @@ func main() { func Minus[K comparable, V any](mapA, mapB map[K]V) map[K]V ``` -Example: +Example:[Run](https://go.dev/play/p/3u5U9K7YZ9m) ```go package main @@ -579,7 +581,7 @@ func main() { func Values[K comparable, V any](m map[K]V) []V ``` -Example: +Example:[Run](https://go.dev/play/p/CBKdUc5FTW6) ```go package main @@ -619,7 +621,7 @@ func main() { func KeysBy[K comparable, V any, T any](m map[K]V, mapper func(item K) T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/hI371iB8Up8) ```go package main @@ -660,7 +662,7 @@ func main() { func ValuesBy[K comparable, V any, T any](m map[K]V, mapper func(item V) T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/sg9-oRidh8f) ```go package main @@ -709,7 +711,7 @@ func main() { func MapKeys[K comparable, V any, T comparable](m map[K]V, iteratee func(key K, value V) T) map[T]V ``` -Example: +Example:[Run](https://go.dev/play/p/8scDxWeBDKd) ```go package main @@ -748,7 +750,7 @@ func main() { func MapValues[K comparable, V any, T any](m map[K]V, iteratee func(key K, value V) T) map[K]T ``` -Example: +Example:[Run](https://go.dev/play/p/g92aY3fc7Iw) ```go package main @@ -791,7 +793,7 @@ type Entry[K comparable, V any] struct { func Entries[K comparable, V any](m map[K]V) []Entry[K, V] ``` -Example: +Example:[Run](https://go.dev/play/p/Ltb11LNcElY) ```go package main @@ -836,7 +838,7 @@ type Entry[K comparable, V any] struct { func FromEntries[K comparable, V any](entries []Entry[K, V]) map[K]V ``` -Example: +Example:[Run](https://go.dev/play/p/fTdu4sCNjQO) ```go package main @@ -870,7 +872,7 @@ func main() { func Transform[K1 comparable, V1 any, K2 comparable, V2 any](m map[K1]V1, iteratee func(key K1, value V1) (K2, V2)) map[K2]V2 ``` -Example: +Example:[Run](https://go.dev/play/p/P6ovfToM3zj) ```go package main @@ -909,7 +911,7 @@ func main() { func IsDisjoint[K comparable, V any](mapA, mapB map[K]V) bool ``` -Example: +Example:[Run](https://go.dev/play/p/N9qgYg_Ho6f) ```go package main @@ -964,7 +966,7 @@ if haskey { func HasKey[K comparable, V any](m map[K]V, key K) bool ``` -Example: +Example:[Run](https://go.dev/play/p/isZZHOsDhFc) ```go package main @@ -1003,7 +1005,7 @@ func main() { func NewConcurrentMap[K comparable, V any](shardCount int) *ConcurrentMap[K, V] ``` -Example: +Example:[Run](https://go.dev/play/p/3PenTPETJT0) ```go package main @@ -1029,7 +1031,7 @@ func main() { func (cm *ConcurrentMap[K, V]) Set(key K, value V) ``` -Example: +Example:[Run](https://go.dev/play/p/3PenTPETJT0) ```go package main @@ -1084,7 +1086,7 @@ func main() { func (cm *ConcurrentMap[K, V]) Get(key K) (V, bool) ``` -Example: +Example:[Run](https://go.dev/play/p/3PenTPETJT0) ```go package main @@ -1139,7 +1141,7 @@ func main() { func (cm *ConcurrentMap[K, V]) GetOrSet(key K, value V) (actual V, ok bool) ``` -Example: +Example:[Run](https://go.dev/play/p/aDcDApOK01a) ```go package main @@ -1183,7 +1185,7 @@ func main() { func (cm *ConcurrentMap[K, V]) Delete(key K) ``` -Example: +Example:[Run](https://go.dev/play/p/uTIJZYhpVMS) ```go package main @@ -1220,7 +1222,6 @@ func main() { } ``` - ### ConcurrentMap_GetAndDelete

Returns the existing value for the key if present and then delete the value for the key. Otherwise, do nothing, just return false.

@@ -1231,7 +1232,7 @@ func main() { func (cm *ConcurrentMap[K, V]) GetAndDelete(key K) (actual V, ok bool) ``` -Example: +Example:[Run](https://go.dev/play/p/ZyxeIXSZUiM) ```go package main @@ -1264,7 +1265,7 @@ func main() { _, ok = cm.Get(fmt.Sprintf("%d", n)) fmt.Println(val, ok) //false - + wg2.Done() }(j) } @@ -1273,7 +1274,6 @@ func main() { } ``` - ### ConcurrentMap_Has

Checks if map has the value for a key.

@@ -1284,7 +1284,7 @@ func main() { func (cm *ConcurrentMap[K, V]) Has(key K) bool ``` -Example: +Example:[Run](https://go.dev/play/p/C8L4ul9TVwf) ```go package main @@ -1321,7 +1321,6 @@ func main() { } ``` - ### ConcurrentMap_Range

Calls iterator sequentially for each key and value present in each of the shards in the map. If iterator returns false, range stops the iteration.

@@ -1332,7 +1331,7 @@ func main() { func (cm *ConcurrentMap[K, V]) Range(iterator func(key K, value V) bool) ``` -Example: +Example:[Run](https://go.dev/play/p/iqcy7P8P0Pr) ```go package main @@ -1356,7 +1355,7 @@ func main() { } wg1.Wait() - + cm.Range(func(key string, value int) bool { fmt.Println(value) return true diff --git a/docs/olddocs/mathutil.md b/docs/en/api/packages/mathutil.md similarity index 86% rename from docs/olddocs/mathutil.md rename to docs/en/api/packages/mathutil.md index 0eebf5f..8b764a7 100644 --- a/docs/olddocs/mathutil.md +++ b/docs/en/api/packages/mathutil.md @@ -48,9 +48,10 @@ import ( - [Sum](#Sum) - [Abs](#Abs) -
+ + ## Documentation ### Average @@ -63,7 +64,7 @@ import ( func Average[T constraints.Integer | constraints.Float](numbers ...T) T ``` -Example: +Example:[Run](https://go.dev/play/p/Vv7LBwER-pz) ```go package main @@ -98,7 +99,7 @@ func main() { func Exponent(x, n int64) int64 ``` -Example: +Example:[Run](https://go.dev/play/p/uF3HGNPk8wr) ```go package main @@ -134,7 +135,7 @@ func main() { func Fibonacci(first, second, n int) int ``` -Example: +Example:[Run](https://go.dev/play/p/IscseUNMuUc) ```go package main @@ -170,7 +171,7 @@ func main() { func Factorial(x uint) uint ``` -Example: +Example:[Run](https://go.dev/play/p/tt6LdOK67Nx) ```go package main @@ -206,7 +207,7 @@ func main() { func Max[T constraints.Integer | constraints.Float](numbers ...T) T ``` -Example: +Example:[Run](https://go.dev/play/p/cN8DHI0rTkH) ```go package main @@ -239,7 +240,7 @@ func main() { func MaxBy[T any](slice []T, comparator func(T, T) bool) T ``` -Example: +Example:[Run](https://go.dev/play/p/pbe2MT-7DV2) ```go package main @@ -283,7 +284,7 @@ func main() { func Min[T constraints.Integer | constraints.Float](numbers ...T) T ``` -Example: +Example:[Run](https://go.dev/play/p/21BER_mlGUj) ```go package main @@ -316,7 +317,7 @@ func main() { func MinBy[T any](slice []T, comparator func(T, T) bool) T ``` -Example: +Example:[Run](https://go.dev/play/p/N9qgYg_Ho6f) ```go package main @@ -360,7 +361,7 @@ func main() { func Percent(val, total float64, n int) float64 ``` -Example: +Example:[Run](https://go.dev/play/p/s0NdFCtwuyd) ```go package main @@ -396,7 +397,7 @@ func main() { func RoundToFloat(x float64, n int) float64 ``` -Example: +Example:[Run](https://go.dev/play/p/ghyb528JRJL) ```go package main @@ -432,7 +433,7 @@ func main() { func RoundToString(x float64, n int) string ``` -Example: +Example:[Run](https://go.dev/play/p/kZwpBRAcllO) ```go package main @@ -468,7 +469,7 @@ func main() { func TruncRound(x float64, n int) float64 ``` -Example: +Example:[Run](https://go.dev/play/p/aumarSHIGzP) ```go package main @@ -504,7 +505,7 @@ func main() { func Range[T constraints.Integer | constraints.Float](start T, count int) []T ``` -Example: +Example:[Run](https://go.dev/play/p/9ke2opxa8ZP) ```go package main @@ -543,7 +544,7 @@ func main() { func RangeWithStep[T constraints.Integer | constraints.Float](start, end, step T) []T ``` -Example: +Example:[Run](https://go.dev/play/p/akLWz0EqOSM) ```go package main @@ -582,7 +583,7 @@ func main() { func AngleToRadian(angle float64) float64 ``` -Example: +Example:[Run](https://go.dev/play/p/CIvlICqrHql) ```go package main @@ -618,7 +619,7 @@ func main() { func RadianToAngle(radian float64) float64 ``` -Example: +Example:[Run](https://go.dev/play/p/dQtmOTUOMgi) ```go package main @@ -654,7 +655,7 @@ func main() { func PointDistance(x1, y1, x2, y2 float64) float64 ``` -Example: +Example:[Run](https://go.dev/play/p/RrG4JIaziM8) ```go package main @@ -684,7 +685,7 @@ func main() { func IsPrime(n int) bool ``` -Example: +Example:[Run](https://go.dev/play/p/Rdd8UTHZJ7u) ```go package main @@ -723,7 +724,7 @@ func main() { func GCD[T constraints.Integer](integers ...T) T ``` -Example: +Example:[Run](https://go.dev/play/p/CiEceLSoAKB) ```go package main @@ -765,7 +766,7 @@ func main() { func LCM[T constraints.Integer](integers ...T) T ``` -Example: +Example:[Run](https://go.dev/play/p/EjcZxfY7G_g) ```go package main @@ -791,7 +792,6 @@ func main() { } ``` - ### Cos

Returns the cosine of the radian argument.

@@ -802,7 +802,7 @@ func main() { func Cos(radian float64, precision ...int) float64 ``` -Example: +Example:[Run](https://go.dev/play/p/Sm89LoIfvFq) ```go package main @@ -834,7 +834,6 @@ func main() { } ``` - ### Sin

Returns the sine of the radian argument.

@@ -845,7 +844,7 @@ func main() { func Sin(radian float64, precision ...int) float64 ``` -Example: +Example:[Run](https://go.dev/play/p/TWMQlMywDsP) ```go package main @@ -887,7 +886,7 @@ func main() { func Log(n, base float64) float64 ``` -Example: +Example:[Run](https://go.dev/play/p/_d4bi8oyhat) ```go package main @@ -923,7 +922,7 @@ func main() { func Sum[T constraints.Integer | constraints.Float](numbers ...T) T ``` -Example: +Example:[Run](https://go.dev/play/p/1To2ImAMJA7) ```go package main @@ -956,7 +955,7 @@ func main() { func Abs[T constraints.Integer | constraints.Float](x T) T ``` -Example: +Example:[Run](https://go.dev/play/p/fsyBh1Os-1d) ```go package main @@ -980,4 +979,4 @@ func main() { // 0.1 // 0.2 } -``` \ No newline at end of file +``` diff --git a/docs/olddocs/netutil.md b/docs/en/api/packages/netutil.md similarity index 92% rename from docs/olddocs/netutil.md rename to docs/en/api/packages/netutil.md index 7e81cda..bf0900c 100644 --- a/docs/olddocs/netutil.md +++ b/docs/en/api/packages/netutil.md @@ -51,6 +51,8 @@ import (
+ + ## Documentation ### ConvertMapToQueryString @@ -63,7 +65,7 @@ import ( func ConvertMapToQueryString(param map[string]any) string ``` -Example: +Example:[Run](https://go.dev/play/p/jnNt_qoSnRi) ```go package main @@ -96,7 +98,7 @@ func main() { func EncodeUrl(urlStr string) (string, error) ``` -Example: +Example:[Run](https://go.dev/play/p/bsZ6BRC4uKI) ```go package main @@ -131,7 +133,7 @@ func main() { func GetInternalIp() string ``` -Example: +Example:[Run](https://go.dev/play/p/5mbu-gFp7ei) ```go package main @@ -163,7 +165,7 @@ func main() { func GetIps() []string ``` -Example: +Example:[Run](https://go.dev/play/p/NUFfcEmukx1) ```go package main @@ -193,7 +195,7 @@ func main() { func GetMacAddrs() []string { ``` -Example: +Example:[Run](https://go.dev/play/p/Rq9UUBS_Xp1) ```go package main @@ -237,7 +239,7 @@ type PublicIpInfo struct { } ``` -Example: +Example:[Run](https://go.dev/play/p/YDxIfozsRHR) ```go package main @@ -267,7 +269,7 @@ func main() { func GetRequestPublicIp(req *http.Request) string ``` -Example: +Example:[Run](https://go.dev/play/p/kxU-YDc_eBo) ```go package main @@ -305,7 +307,7 @@ func main() { func IsPublicIP(IP net.IP) bool ``` -Example: +Example:[Run](https://go.dev/play/p/nmktSQpJZnn) ```go package main @@ -342,7 +344,7 @@ func main() { func IsInternalIP(IP net.IP) bool ``` -Example: +Example:[Run](https://go.dev/play/p/sYGhXbgO4Cb) ```go package main @@ -386,7 +388,7 @@ type HttpRequest struct { } ``` -Example: +Example:[Run](https://go.dev/play/p/jUSgynekH7G) ```go package main @@ -443,7 +445,7 @@ func NewHttpClientWithConfig(config *HttpClientConfig) *HttpClient ``` -Example: +Example:[Run](https://go.dev/play/p/jUSgynekH7G) ```go package main @@ -474,7 +476,7 @@ func main() { func (client *HttpClient) SendRequest(request *HttpRequest) (*http.Response, error) ``` -Example: +Example:[Run](https://go.dev/play/p/jUSgynekH7G) ```go package main @@ -528,7 +530,7 @@ func main() { func (client *HttpClient) DecodeResponse(resp *http.Response, target any) error ``` -Example: +Example:[Run](https://go.dev/play/p/jUSgynekH7G) ```go package main @@ -582,7 +584,7 @@ func main() { func StructToUrlValues(targetStruct any) url.Values ``` -Example: +Example:[Run](https://go.dev/play/p/pFqMkM40w9z) ```go package main @@ -964,7 +966,7 @@ func main() { func IsPingConnected(host string) bool ``` -Example: +Example:[Run](https://go.dev/play/p/q8OzTijsA87) ```go package main @@ -997,7 +999,7 @@ func main() { func IsTelnetConnected(host string, port string) bool ``` -Example: +Example:[Run](https://go.dev/play/p/yiLCGtQv_ZG) ```go package main diff --git a/docs/olddocs/pointer.md b/docs/en/api/packages/pointer.md similarity index 85% rename from docs/olddocs/pointer.md rename to docs/en/api/packages/pointer.md index fd221bb..80a3488 100644 --- a/docs/olddocs/pointer.md +++ b/docs/en/api/packages/pointer.md @@ -30,6 +30,8 @@ import (
+ + ## Documentation ### Of @@ -42,7 +44,7 @@ import ( func Of[T any](v T) *T ``` -Example: +Example:[Run](https://go.dev/play/p/HFd70x4DrMj) ```go package main @@ -76,7 +78,7 @@ func main() { func Unwrap[T any](p *T) T ``` -Example: +Example:[Run](https://go.dev/play/p/cgeu3g7cjWb) ```go package main @@ -112,7 +114,7 @@ func main() { UnwarpOr[T any](p *T, fallback T) T ``` -Example: +Example:[Run](https://go.dev/play/p/mmNaLC38W8C) ```go package main @@ -157,7 +159,7 @@ func main() { UnwarpOrDefault[T any](p *T) T ``` -Example: +Example:[Run](https://go.dev/play/p/ZnGIHf8_o4E) ```go package main @@ -203,7 +205,7 @@ func main() { func ExtractPointer(value any) any ``` -Example: +Example:[Run](https://go.dev/play/p/D7HFjeWU2ZP) ```go package main diff --git a/mathutil/mathutil.go b/mathutil/mathutil.go index 8a1b070..f5aaab4 100644 --- a/mathutil/mathutil.go +++ b/mathutil/mathutil.go @@ -343,7 +343,7 @@ func Log(n, base float64) float64 { } // Abs returns the absolute value of x. -// Play: todo +// Play: https://go.dev/play/p/fsyBh1Os-1d func Abs[T constraints.Integer | constraints.Float](x T) T { if x < 0 { return (-x)