mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
docs: update doc
This commit is contained in:
@@ -90,6 +90,10 @@ export const enConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
|
||||
{ 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' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -86,7 +86,10 @@ export const zhConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
|
||||
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<DefaultTheme.Config> = {
|
||||
{ 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' },
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -53,9 +53,10 @@ import (
|
||||
- [ConcurrentMap_Has](#ConcurrentMap_Has)
|
||||
- [ConcurrentMap_Range](#ConcurrentMap_Range)
|
||||
|
||||
|
||||
<div STYLE="page-break-after: always;"></div>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../../styles/api_doc.css">
|
||||
|
||||
## API 文档:
|
||||
|
||||
### <span id="MapTo">MapTo</span>
|
||||
@@ -68,7 +69,7 @@ import (
|
||||
func MapTo(src any, dst any) error
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/4K7KBEPgS5M)</span></b>
|
||||
|
||||
```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))
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/OaThj6iNVXK)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/fSvF3wxuNG7)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -211,7 +212,7 @@ func main() {
|
||||
func FilterByKeys[K comparable, V any](m map[K]V, keys []K) map[K]V
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/7ov6BJHbVqh)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -249,7 +250,7 @@ func main() {
|
||||
func FilterByValues[K comparable, V comparable](m map[K]V, values []V) map[K]V
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/P3-9MdcXegR)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/YJM4Hj5hNwm)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -328,7 +329,7 @@ func main() {
|
||||
func OmitByKeys[K comparable, V any](m map[K]V, keys []K) map[K]V
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/jXGrWDBfSRp)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -366,7 +367,7 @@ func main() {
|
||||
func OmitByValues[K comparable, V comparable](m map[K]V, values []V) map[K]V
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/XB7Y10uw20_U)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -404,7 +405,7 @@ func main() {
|
||||
func Intersect[K comparable, V any](maps ...map[K]V) map[K]V
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/Zld0oj3sjcC)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -459,7 +460,7 @@ func main() {
|
||||
func Keys[K comparable, V any](m map[K]V) []K
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/xNB5bTb97Wd)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -498,7 +499,7 @@ func main() {
|
||||
func Merge[K comparable, V any](maps ...map[K]V) map[K]V
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/H95LENF1uB-)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -537,7 +538,7 @@ func main() {
|
||||
func Minus[K comparable, V any](mapA, mapB map[K]V) map[K]V
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/3u5U9K7YZ9m)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -579,7 +580,7 @@ func main() {
|
||||
func Values[K comparable, V any](m map[K]V) []V
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/CBKdUc5FTW6)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/hI371iB8Up8)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/sg9-oRidh8f)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/8scDxWeBDKd)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/g92aY3fc7Iw)</span></b>
|
||||
|
||||
```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]
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/Ltb11LNcElY)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/C8L4ul9TVwf)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/P6ovfToM3zj)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -906,7 +907,7 @@ func main() {
|
||||
func IsDisjoint[K comparable, V any](mapA, mapB map[K]V) bool
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/N9qgYg_Ho6f)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -961,7 +962,7 @@ if haskey {
|
||||
func HasKey[K comparable, V any](m map[K]V, key K) bool
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/isZZHOsDhFc)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1000,7 +1001,7 @@ func main() {
|
||||
func NewConcurrentMap[K comparable, V any](shardCount int) *ConcurrentMap[K, V]
|
||||
```
|
||||
|
||||
<b>实例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/3PenTPETJT0)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1026,7 +1027,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) Set(key K, value V)
|
||||
```
|
||||
|
||||
<b>实例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/3PenTPETJT0)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1080,7 +1081,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) Get(key K) (V, bool)
|
||||
```
|
||||
|
||||
<b>实例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/3PenTPETJT0)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1134,7 +1135,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) GetOrSet(key K, value V) (actual V, ok bool)
|
||||
```
|
||||
|
||||
<b>实例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/aDcDApOK01a)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1178,7 +1179,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) Delete(key K)
|
||||
```
|
||||
|
||||
<b>实例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/uTIJZYhpVMS)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1214,7 +1215,6 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### <span id="ConcurrentMap_GetAndDelete">ConcurrentMap_GetAndDelete</span>
|
||||
|
||||
<p>获取key,然后删除。</p>
|
||||
@@ -1225,7 +1225,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) GetAndDelete(key K) (actual V, ok bool)
|
||||
```
|
||||
|
||||
<b>实例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/ZyxeIXSZUiM)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1266,7 +1266,6 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### <span id="ConcurrentMap_Has">ConcurrentMap_Has</span>
|
||||
|
||||
<p>验证是否包含key。</p>
|
||||
@@ -1277,7 +1276,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) Has(key K) bool
|
||||
```
|
||||
|
||||
<b>实例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/C8L4ul9TVwf)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1315,7 +1314,6 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### <span id="ConcurrentMap_Range">ConcurrentMap_Range</span>
|
||||
|
||||
<p>为map中每个键和值顺序调用迭代器。 如果iterator返回false,则停止迭代。</p>
|
||||
@@ -1326,7 +1324,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) Range(iterator func(key K, value V) bool)
|
||||
```
|
||||
|
||||
<b>实例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/iqcy7P8P0Pr)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1357,4 +1355,3 @@ func main() {
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
@@ -50,7 +50,9 @@ import (
|
||||
|
||||
<div STYLE="page-break-after: always;"></div>
|
||||
|
||||
## Documentation
|
||||
<link rel="stylesheet" type="text/css" href="../../styles/api_doc.css">
|
||||
|
||||
## 文档
|
||||
|
||||
### <span id="Average">Average</span>
|
||||
|
||||
@@ -97,7 +99,7 @@ func main() {
|
||||
func Exponent(x, n int64) int64
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/Vv7LBwER-pz)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -133,7 +135,7 @@ func main() {
|
||||
func Fibonacci(first, second, n int) int
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/IscseUNMuUc)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -169,7 +171,7 @@ func main() {
|
||||
func Factorial(x uint) uint
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/tt6LdOK67Nx)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -205,7 +207,7 @@ func main() {
|
||||
func Max[T constraints.Integer | constraints.Float](numbers ...T) T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/cN8DHI0rTkH)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -238,7 +240,7 @@ func main() {
|
||||
func MaxBy[T any](slice []T, comparator func(T, T) bool) T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/pbe2MT-7DV2)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -282,7 +284,7 @@ func main() {
|
||||
func Min[T constraints.Integer | constraints.Float](numbers ...T) T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/pbe2MT-7DV2)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -315,7 +317,7 @@ func main() {
|
||||
func MinBy[T any](slice []T, comparator func(T, T) bool) T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/N9qgYg_Ho6f)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -359,7 +361,7 @@ func main() {
|
||||
func Percent(val, total float64, n int) float64
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/s0NdFCtwuyd)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -395,7 +397,7 @@ func main() {
|
||||
func RoundToFloat(x float64, n int) float64
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/ghyb528JRJL)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -431,7 +433,7 @@ func main() {
|
||||
func RoundToString(x float64, n int) string
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/kZwpBRAcllO)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -467,7 +469,7 @@ func main() {
|
||||
func TruncRound(x float64, n int) float64
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/aumarSHIGzP)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -503,7 +505,7 @@ func main() {
|
||||
func Range[T constraints.Integer | constraints.Float](start T, count int) []T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/9ke2opxa8ZP)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -542,7 +544,7 @@ func main() {
|
||||
func RangeWithStep[T constraints.Integer | constraints.Float](start, end, step T) []T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/akLWz0EqOSM)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -581,7 +583,7 @@ func main() {
|
||||
func AngleToRadian(angle float64) float64
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/CIvlICqrHql)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -617,7 +619,7 @@ func main() {
|
||||
func RadianToAngle(radian float64) float64
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/dQtmOTUOMgi)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -653,7 +655,7 @@ func main() {
|
||||
func PointDistance(x1, y1, x2, y2 float64) float64
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/RrG4JIaziM8)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -683,7 +685,7 @@ func main() {
|
||||
func IsPrime(n int) bool
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/Rdd8UTHZJ7u)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -722,7 +724,7 @@ func main() {
|
||||
func GCD[T constraints.Integer](integers ...T) T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/CiEceLSoAKB)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -764,7 +766,7 @@ func main() {
|
||||
func LCM[T constraints.Integer](integers ...T) T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/EjcZxfY7G_g)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -800,7 +802,7 @@ func main() {
|
||||
func Cos(radian float64, precision ...int) float64
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/Sm89LoIfvFq)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -842,7 +844,7 @@ func main() {
|
||||
func Sin(radian float64, precision ...int) float64
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/TWMQlMywDsP)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -884,7 +886,7 @@ func main() {
|
||||
func Log(n, base float64) float64
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/_d4bi8oyhat)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -920,7 +922,7 @@ func main() {
|
||||
func Sum[T constraints.Integer | constraints.Float](numbers ...T) T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/1To2ImAMJA7)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -953,7 +955,7 @@ func main() {
|
||||
func Abs[T constraints.Integer | constraints.Float](x T) T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/fsyBh1Os-1d)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -51,6 +51,8 @@ import (
|
||||
|
||||
<div STYLE="page-break-after: always;"></div>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../../styles/api_doc.css">
|
||||
|
||||
## 文档
|
||||
|
||||
### <span id="ConvertMapToQueryString">ConvertMapToQueryString</span>
|
||||
@@ -63,7 +65,7 @@ import (
|
||||
func ConvertMapToQueryString(param map[string]any) string
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/jnNt_qoSnRi)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -98,7 +100,7 @@ func main() {
|
||||
func EncodeUrl(urlStr string) (string, error)
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/bsZ6BRC4uKI)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -133,7 +135,7 @@ func main() {
|
||||
func GetInternalIp() string
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/fxnna_LLD9u)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -165,7 +167,7 @@ func main() {
|
||||
func GetIps() []string
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/NUFfcEmukx1)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -195,7 +197,7 @@ func main() {
|
||||
func GetMacAddrs() []string {
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/Rq9UUBS_Xp1)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -239,7 +241,7 @@ type PublicIpInfo struct {
|
||||
}
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/YDxIfozsRHR)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -269,7 +271,7 @@ func main() {
|
||||
func GetRequestPublicIp(req *http.Request) string
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/kxU-YDc_eBo)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -307,7 +309,7 @@ func main() {
|
||||
func IsPublicIP(IP net.IP) bool
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/nmktSQpJZnn)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -344,7 +346,7 @@ func main() {
|
||||
func IsInternalIP(IP net.IP) bool
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/sYGhXbgO4Cb)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -388,7 +390,7 @@ type HttpRequest struct {
|
||||
}
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/jUSgynekH7G)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -445,7 +447,7 @@ func NewHttpClientWithConfig(config *HttpClientConfig) *HttpClient
|
||||
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/jUSgynekH7G)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -476,7 +478,7 @@ func main() {
|
||||
func (client *HttpClient) SendRequest(request *HttpRequest) (*http.Response, error)
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/jUSgynekH7G)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -530,7 +532,7 @@ func main() {
|
||||
func (client *HttpClient) DecodeResponse(resp *http.Response, target any) error
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/jUSgynekH7G)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -584,7 +586,7 @@ func main() {
|
||||
func StructToUrlValues(targetStruct any) url.Values
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/pFqMkM40w9z)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -966,7 +968,7 @@ func main() {
|
||||
func IsPingConnected(host string) bool
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/q8OzTijsA87)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -999,7 +1001,7 @@ func main() {
|
||||
func IsTelnetConnected(host string, port string) bool
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/yiLCGtQv_ZG)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -30,6 +30,8 @@ import (
|
||||
|
||||
<div STYLE="page-break-after: always;"></div>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../../styles/api_doc.css">
|
||||
|
||||
## 文档
|
||||
|
||||
### <span id="Of">Of</span>
|
||||
@@ -42,7 +44,7 @@ import (
|
||||
func Of[T any](v T) *T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/HFd70x4DrMj)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -75,7 +77,7 @@ func main() {
|
||||
func Unwrap[T any](p *T) T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/cgeu3g7cjWb)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -111,7 +113,7 @@ func main() {
|
||||
func ExtractPointer(value any) any
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/D7HFjeWU2ZP)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -146,7 +148,7 @@ func main() {
|
||||
UnwarpOr[T any](p *T, fallback T) T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/mmNaLC38W8C)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -191,7 +193,7 @@ func main() {
|
||||
UnwarpOrDefault[T any](p *T) T
|
||||
```
|
||||
|
||||
<b>示例:</b>
|
||||
<b>示例:<span class="run-container">[运行](https://go.dev/play/p/ZnGIHf8_o4E)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -55,6 +55,8 @@ import (
|
||||
|
||||
<div STYLE="page-break-after: always;"></div>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../../styles/api_doc.css">
|
||||
|
||||
## Documentation
|
||||
|
||||
### <span id="MapTo">MapTo</span>
|
||||
@@ -67,7 +69,7 @@ import (
|
||||
func MapTo(src any, dst any) error
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/4K7KBEPgS5M)</span></b>
|
||||
|
||||
```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))
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/OaThj6iNVXK)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/fSvF3wxuNG7)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -210,7 +212,7 @@ func main() {
|
||||
func FilterByKeys[K comparable, V any](m map[K]V, keys []K) map[K]V
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/7ov6BJHbVqh)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -248,7 +250,7 @@ func main() {
|
||||
func FilterByValues[K comparable, V comparable](m map[K]V, values []V) map[K]V
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/P3-9MdcXegR)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/YJM4Hj5hNwm)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -327,7 +329,7 @@ func main() {
|
||||
func OmitByKeys[K comparable, V any](m map[K]V, keys []K) map[K]V
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/jXGrWDBfSRp)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -365,7 +367,7 @@ func main() {
|
||||
func OmitByValues[K comparable, V comparable](m map[K]V, values []V) map[K]V
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/XB7Y10uw20_U)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -403,7 +405,7 @@ func main() {
|
||||
func Intersect[K comparable, V any](maps ...map[K]V) map[K]V
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/Zld0oj3sjcC)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -458,7 +460,7 @@ func main() {
|
||||
func Keys[K comparable, V any](m map[K]V) []K
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/xNB5bTb97Wd)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -498,7 +500,7 @@ func main() {
|
||||
func Merge[K comparable, V any](maps ...map[K]V) map[K]V
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/H95LENF1uB-)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -537,7 +539,7 @@ func main() {
|
||||
func Minus[K comparable, V any](mapA, mapB map[K]V) map[K]V
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/3u5U9K7YZ9m)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -579,7 +581,7 @@ func main() {
|
||||
func Values[K comparable, V any](m map[K]V) []V
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/CBKdUc5FTW6)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/hI371iB8Up8)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/sg9-oRidh8f)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/8scDxWeBDKd)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/g92aY3fc7Iw)</span></b>
|
||||
|
||||
```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]
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/Ltb11LNcElY)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/fTdu4sCNjQO)</span></b>
|
||||
|
||||
```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
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/P6ovfToM3zj)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -909,7 +911,7 @@ func main() {
|
||||
func IsDisjoint[K comparable, V any](mapA, mapB map[K]V) bool
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/N9qgYg_Ho6f)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -964,7 +966,7 @@ if haskey {
|
||||
func HasKey[K comparable, V any](m map[K]V, key K) bool
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/isZZHOsDhFc)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1003,7 +1005,7 @@ func main() {
|
||||
func NewConcurrentMap[K comparable, V any](shardCount int) *ConcurrentMap[K, V]
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/3PenTPETJT0)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1029,7 +1031,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) Set(key K, value V)
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/3PenTPETJT0)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1084,7 +1086,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) Get(key K) (V, bool)
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/3PenTPETJT0)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1139,7 +1141,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) GetOrSet(key K, value V) (actual V, ok bool)
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/aDcDApOK01a)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1183,7 +1185,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) Delete(key K)
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/uTIJZYhpVMS)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1220,7 +1222,6 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### <span id="ConcurrentMap_GetAndDelete">ConcurrentMap_GetAndDelete</span>
|
||||
|
||||
<p>Returns the existing value for the key if present and then delete the value for the key. Otherwise, do nothing, just return false.</p>
|
||||
@@ -1231,7 +1232,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) GetAndDelete(key K) (actual V, ok bool)
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/ZyxeIXSZUiM)</span></b>
|
||||
|
||||
```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() {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### <span id="ConcurrentMap_Has">ConcurrentMap_Has</span>
|
||||
|
||||
<p>Checks if map has the value for a key.</p>
|
||||
@@ -1284,7 +1284,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) Has(key K) bool
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/C8L4ul9TVwf)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1321,7 +1321,6 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### <span id="ConcurrentMap_Range">ConcurrentMap_Range</span>
|
||||
|
||||
<p>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.</p>
|
||||
@@ -1332,7 +1331,7 @@ func main() {
|
||||
func (cm *ConcurrentMap[K, V]) Range(iterator func(key K, value V) bool)
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/iqcy7P8P0Pr)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -1356,7 +1355,7 @@ func main() {
|
||||
}
|
||||
wg1.Wait()
|
||||
|
||||
|
||||
|
||||
cm.Range(func(key string, value int) bool {
|
||||
fmt.Println(value)
|
||||
return true
|
||||
@@ -48,9 +48,10 @@ import (
|
||||
- [Sum](#Sum)
|
||||
- [Abs](#Abs)
|
||||
|
||||
|
||||
<div STYLE="page-break-after: always;"></div>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../../styles/api_doc.css">
|
||||
|
||||
## Documentation
|
||||
|
||||
### <span id="Average">Average</span>
|
||||
@@ -63,7 +64,7 @@ import (
|
||||
func Average[T constraints.Integer | constraints.Float](numbers ...T) T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/Vv7LBwER-pz)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -98,7 +99,7 @@ func main() {
|
||||
func Exponent(x, n int64) int64
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/uF3HGNPk8wr)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -134,7 +135,7 @@ func main() {
|
||||
func Fibonacci(first, second, n int) int
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/IscseUNMuUc)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -170,7 +171,7 @@ func main() {
|
||||
func Factorial(x uint) uint
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/tt6LdOK67Nx)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -206,7 +207,7 @@ func main() {
|
||||
func Max[T constraints.Integer | constraints.Float](numbers ...T) T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/cN8DHI0rTkH)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -239,7 +240,7 @@ func main() {
|
||||
func MaxBy[T any](slice []T, comparator func(T, T) bool) T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/pbe2MT-7DV2)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -283,7 +284,7 @@ func main() {
|
||||
func Min[T constraints.Integer | constraints.Float](numbers ...T) T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/21BER_mlGUj)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -316,7 +317,7 @@ func main() {
|
||||
func MinBy[T any](slice []T, comparator func(T, T) bool) T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/N9qgYg_Ho6f)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -360,7 +361,7 @@ func main() {
|
||||
func Percent(val, total float64, n int) float64
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/s0NdFCtwuyd)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -396,7 +397,7 @@ func main() {
|
||||
func RoundToFloat(x float64, n int) float64
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/ghyb528JRJL)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -432,7 +433,7 @@ func main() {
|
||||
func RoundToString(x float64, n int) string
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/kZwpBRAcllO)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -468,7 +469,7 @@ func main() {
|
||||
func TruncRound(x float64, n int) float64
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/aumarSHIGzP)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -504,7 +505,7 @@ func main() {
|
||||
func Range[T constraints.Integer | constraints.Float](start T, count int) []T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/9ke2opxa8ZP)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -543,7 +544,7 @@ func main() {
|
||||
func RangeWithStep[T constraints.Integer | constraints.Float](start, end, step T) []T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/akLWz0EqOSM)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -582,7 +583,7 @@ func main() {
|
||||
func AngleToRadian(angle float64) float64
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/CIvlICqrHql)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -618,7 +619,7 @@ func main() {
|
||||
func RadianToAngle(radian float64) float64
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/dQtmOTUOMgi)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -654,7 +655,7 @@ func main() {
|
||||
func PointDistance(x1, y1, x2, y2 float64) float64
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/RrG4JIaziM8)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -684,7 +685,7 @@ func main() {
|
||||
func IsPrime(n int) bool
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/Rdd8UTHZJ7u)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -723,7 +724,7 @@ func main() {
|
||||
func GCD[T constraints.Integer](integers ...T) T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/CiEceLSoAKB)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -765,7 +766,7 @@ func main() {
|
||||
func LCM[T constraints.Integer](integers ...T) T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/EjcZxfY7G_g)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -791,7 +792,6 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### <span id="Cos">Cos</span>
|
||||
|
||||
<p>Returns the cosine of the radian argument.</p>
|
||||
@@ -802,7 +802,7 @@ func main() {
|
||||
func Cos(radian float64, precision ...int) float64
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/Sm89LoIfvFq)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -834,7 +834,6 @@ func main() {
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
### <span id="Sin">Sin</span>
|
||||
|
||||
<p>Returns the sine of the radian argument.</p>
|
||||
@@ -845,7 +844,7 @@ func main() {
|
||||
func Sin(radian float64, precision ...int) float64
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/TWMQlMywDsP)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -887,7 +886,7 @@ func main() {
|
||||
func Log(n, base float64) float64
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/_d4bi8oyhat)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -923,7 +922,7 @@ func main() {
|
||||
func Sum[T constraints.Integer | constraints.Float](numbers ...T) T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/1To2ImAMJA7)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -956,7 +955,7 @@ func main() {
|
||||
func Abs[T constraints.Integer | constraints.Float](x T) T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/fsyBh1Os-1d)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -980,4 +979,4 @@ func main() {
|
||||
// 0.1
|
||||
// 0.2
|
||||
}
|
||||
```
|
||||
```
|
||||
@@ -51,6 +51,8 @@ import (
|
||||
|
||||
<div STYLE="page-break-after: always;"></div>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../../styles/api_doc.css">
|
||||
|
||||
## Documentation
|
||||
|
||||
### <span id="ConvertMapToQueryString">ConvertMapToQueryString</span>
|
||||
@@ -63,7 +65,7 @@ import (
|
||||
func ConvertMapToQueryString(param map[string]any) string
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/jnNt_qoSnRi)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -96,7 +98,7 @@ func main() {
|
||||
func EncodeUrl(urlStr string) (string, error)
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/bsZ6BRC4uKI)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -131,7 +133,7 @@ func main() {
|
||||
func GetInternalIp() string
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/5mbu-gFp7ei)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -163,7 +165,7 @@ func main() {
|
||||
func GetIps() []string
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/NUFfcEmukx1)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -193,7 +195,7 @@ func main() {
|
||||
func GetMacAddrs() []string {
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/Rq9UUBS_Xp1)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -237,7 +239,7 @@ type PublicIpInfo struct {
|
||||
}
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/YDxIfozsRHR)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -267,7 +269,7 @@ func main() {
|
||||
func GetRequestPublicIp(req *http.Request) string
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/kxU-YDc_eBo)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -305,7 +307,7 @@ func main() {
|
||||
func IsPublicIP(IP net.IP) bool
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/nmktSQpJZnn)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -342,7 +344,7 @@ func main() {
|
||||
func IsInternalIP(IP net.IP) bool
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/sYGhXbgO4Cb)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -386,7 +388,7 @@ type HttpRequest struct {
|
||||
}
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/jUSgynekH7G)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -443,7 +445,7 @@ func NewHttpClientWithConfig(config *HttpClientConfig) *HttpClient
|
||||
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/jUSgynekH7G)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -474,7 +476,7 @@ func main() {
|
||||
func (client *HttpClient) SendRequest(request *HttpRequest) (*http.Response, error)
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/jUSgynekH7G)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -528,7 +530,7 @@ func main() {
|
||||
func (client *HttpClient) DecodeResponse(resp *http.Response, target any) error
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/jUSgynekH7G)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -582,7 +584,7 @@ func main() {
|
||||
func StructToUrlValues(targetStruct any) url.Values
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/pFqMkM40w9z)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -964,7 +966,7 @@ func main() {
|
||||
func IsPingConnected(host string) bool
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/q8OzTijsA87)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -997,7 +999,7 @@ func main() {
|
||||
func IsTelnetConnected(host string, port string) bool
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/yiLCGtQv_ZG)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -30,6 +30,8 @@ import (
|
||||
|
||||
<div STYLE="page-break-after: always;"></div>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="../../styles/api_doc.css">
|
||||
|
||||
## Documentation
|
||||
|
||||
### <span id="Of">Of</span>
|
||||
@@ -42,7 +44,7 @@ import (
|
||||
func Of[T any](v T) *T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/HFd70x4DrMj)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -76,7 +78,7 @@ func main() {
|
||||
func Unwrap[T any](p *T) T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/cgeu3g7cjWb)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -112,7 +114,7 @@ func main() {
|
||||
UnwarpOr[T any](p *T, fallback T) T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/mmNaLC38W8C)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -157,7 +159,7 @@ func main() {
|
||||
UnwarpOrDefault[T any](p *T) T
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/ZnGIHf8_o4E)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -203,7 +205,7 @@ func main() {
|
||||
func ExtractPointer(value any) any
|
||||
```
|
||||
|
||||
<b>Example:</b>
|
||||
<b>Example:<span class="run-container">[Run](https://go.dev/play/p/D7HFjeWU2ZP)</span></b>
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user