mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
doc: update doc for v2.3.4
This commit is contained in:
67
README.md
67
README.md
@@ -4,7 +4,7 @@
|
|||||||
<br/>
|
<br/>
|
||||||
|
|
||||||

|

|
||||||
[](https://github.com/duke-git/lancet/releases)
|
[](https://github.com/duke-git/lancet/releases)
|
||||||
[](https://pkg.go.dev/github.com/duke-git/lancet/v2)
|
[](https://pkg.go.dev/github.com/duke-git/lancet/v2)
|
||||||
[](https://goreportcard.com/report/github.com/duke-git/lancet/v2)
|
[](https://goreportcard.com/report/github.com/duke-git/lancet/v2)
|
||||||
[](https://github.com/duke-git/lancet/actions/workflows/codecov.yml)
|
[](https://github.com/duke-git/lancet/actions/workflows/codecov.yml)
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
go get github.com/duke-git/lancet/v2 // will install latest version of v2.x.x
|
go get github.com/duke-git/lancet/v2 // will install latest version of v2.x.x
|
||||||
```
|
```
|
||||||
|
|
||||||
2. <b>For users who use version below go1.18, you should install v1.x.x. The latest of v1.x.x is v1.4.4. </b>
|
2. <b>For users who use version below go1.18, you should install v1.x.x. The latest of v1.x.x is v1.4.5. </b>
|
||||||
|
|
||||||
```go
|
```go
|
||||||
go get github.com/duke-git/lancet // below go1.18, install latest version of v1.x.x
|
go get github.com/duke-git/lancet // below go1.18, install latest version of v1.x.x
|
||||||
@@ -321,12 +321,19 @@ import "github.com/duke-git/lancet/v2/convertor"
|
|||||||
[[play](https://go.dev/play/p/OphmHCN_9u8)]
|
[[play](https://go.dev/play/p/OphmHCN_9u8)]
|
||||||
- **<big>ToStdBase64</big>** : converts a value to a string encoded in standard Base64.
|
- **<big>ToStdBase64</big>** : converts a value to a string encoded in standard Base64.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/convertor.md#ToStdBase64)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/convertor.md#ToStdBase64)]
|
||||||
|
[[play](https://go.dev/play/p/_fLJqJD3NMo)]
|
||||||
- **<big>ToUrlBase64</big>** : converts a value to a string encoded in url Base64.
|
- **<big>ToUrlBase64</big>** : converts a value to a string encoded in url Base64.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/convertor.md#ToUrlBase64)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/convertor.md#ToUrlBase64)]
|
||||||
|
[[play](https://go.dev/play/p/C_d0GlvEeUR)]
|
||||||
- **<big>ToRawStdBase64</big>** : converts a value to a string encoded in raw standard Base64.
|
- **<big>ToRawStdBase64</big>** : converts a value to a string encoded in raw standard Base64.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/convertor.md#ToRawStdBase64)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/convertor.md#ToRawStdBase64)]
|
||||||
|
[[play](https://go.dev/play/p/wSAr3sfkDcv)]
|
||||||
- **<big>ToRawUrlBase64</big>** : converts a value to a string encoded in raw url Base64.
|
- **<big>ToRawUrlBase64</big>** : converts a value to a string encoded in raw url Base64.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/convertor.md#ToRawUrlBase64)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/convertor.md#ToRawUrlBase64)]
|
||||||
|
[[play](https://go.dev/play/p/HwdDPFcza1O)]
|
||||||
|
- **<big>ToBigInt</big>** : converts an integer of any supported type (int, int64, uint64, etc.) to *big.Int.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/convertor.md#ToBigInt)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="cryptor"> 6. Cryptor package is for data encryption and decryption. <a href="#index">index</a></h3>
|
<h3 id="cryptor"> 6. Cryptor package is for data encryption and decryption. <a href="#index">index</a></h3>
|
||||||
|
|
||||||
@@ -475,7 +482,12 @@ import "github.com/duke-git/lancet/v2/cryptor"
|
|||||||
- **<big>RsaDecryptOAEP</big>** : decrypts the data with RSA-OAEP
|
- **<big>RsaDecryptOAEP</big>** : decrypts the data with RSA-OAEP
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/cryptor.md#RsaDecryptOAEP)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/cryptor.md#RsaDecryptOAEP)]
|
||||||
[[play](https://go.dev/play/p/sSVmkfENKMz)]
|
[[play](https://go.dev/play/p/sSVmkfENKMz)]
|
||||||
|
- **<big>RsaSign</big>** : signs the data with RSA.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/cryptor.md#RsaSign)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>RsaVerifySign</big>** : verifies the signature of the data with RSA.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/cryptor.md#RsaVerifySign)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="datetime"> 7. Datetime package supports date and time format and compare. <a href="#index">index</a></h3>
|
<h3 id="datetime"> 7. Datetime package supports date and time format and compare. <a href="#index">index</a></h3>
|
||||||
|
|
||||||
@@ -619,7 +631,15 @@ import "github.com/duke-git/lancet/v2/datetime"
|
|||||||
- **<big>GenerateDatetimesBetween</big>** : returns a slice of strings between two times.
|
- **<big>GenerateDatetimesBetween</big>** : returns a slice of strings between two times.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#GenerateDatetimesBetween)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#GenerateDatetimesBetween)]
|
||||||
[[play](https://go.dev/play/p/6kHBpAxD9ZC)]
|
[[play](https://go.dev/play/p/6kHBpAxD9ZC)]
|
||||||
|
- **<big>Min</big>** : returns the earliest time among the given times.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#Min)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>Max</big>** : returns the latest time among the given times.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#Max)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>MaxMin</big>** : returns the latest and earliest time among the given times.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#MaxMin)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="datastructure"> 8. Datastructure package contains some common data structure. eg. list, linklist, stack, queue, set, tree, graph. <a href="#index">index</a></h3>
|
<h3 id="datastructure"> 8. Datastructure package contains some common data structure. eg. list, linklist, stack, queue, set, tree, graph. <a href="#index">index</a></h3>
|
||||||
|
|
||||||
@@ -755,6 +775,9 @@ import "github.com/duke-git/lancet/v2/fileutil"
|
|||||||
- **<big>ParallelChunkRead</big>** : reads the file in parallel and send each chunk of lines to the specified channel.
|
- **<big>ParallelChunkRead</big>** : reads the file in parallel and send each chunk of lines to the specified channel.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/fileutil.md#ParallelChunkRead)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/fileutil.md#ParallelChunkRead)]
|
||||||
[[play](https://go.dev/play/p/teMXnCsdSEw)]
|
[[play](https://go.dev/play/p/teMXnCsdSEw)]
|
||||||
|
- **<big>GetExeOrDllVersion</big>** : Get the version of exe or dll file on windows os.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/fileutil.md#GetExeOrDllVersion)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="formatter"> 10. Formatter contains some functions for data formatting. <a href="#index">index</a></h3>
|
<h3 id="formatter"> 10. Formatter contains some functions for data formatting. <a href="#index">index</a></h3>
|
||||||
|
|
||||||
@@ -1120,7 +1143,18 @@ import "github.com/duke-git/lancet/v2/mathutil"
|
|||||||
- **<big>Div</big>** : returns the result of x divided by y.
|
- **<big>Div</big>** : returns the result of x divided by y.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/mathutil.md#Div)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/mathutil.md#Div)]
|
||||||
[[play](https://go.dev/play/p/WLxDdGXXYat)]
|
[[play](https://go.dev/play/p/WLxDdGXXYat)]
|
||||||
|
- **<big>Variance</big>** : returns the variance of numbers.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/mathutil.md#Variance)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>StdDev</big>** : returns the standard deviation of numbers.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/mathutil.md#StdDev)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>Permutation</big>** : calculates P(n, k).
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/mathutil.md#Permutation)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>Combination</big>** : calculates C(n, k).
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/mathutil.md#Combination)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="netutil"> 14. Netutil package contains functions to get net information and send http request. <a href="#index">index</a></h3>
|
<h3 id="netutil"> 14. Netutil package contains functions to get net information and send http request. <a href="#index">index</a></h3>
|
||||||
|
|
||||||
@@ -1281,7 +1315,9 @@ import "github.com/duke-git/lancet/v2/random"
|
|||||||
- **<big>RandSliceFromGivenSlice</big>** : generate a random slice of length num from given slice.
|
- **<big>RandSliceFromGivenSlice</big>** : generate a random slice of length num from given slice.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandSliceFromGivenSlice)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandSliceFromGivenSlice)]
|
||||||
[[play](https://go.dev/play/p/68UikN9d6VT)]
|
[[play](https://go.dev/play/p/68UikN9d6VT)]
|
||||||
|
- **<big>RandNumberOfLength</big>** : generates a random int number of specified length.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandNumberOfLength)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="retry"> 17. Retry package is for executing a function repeatedly until it was successful or canceled by the context. <a href="#index">index</a></h3>
|
<h3 id="retry"> 17. Retry package is for executing a function repeatedly until it was successful or canceled by the context. <a href="#index">index</a></h3>
|
||||||
|
|
||||||
@@ -1575,7 +1611,12 @@ import "github.com/duke-git/lancet/v2/slice"
|
|||||||
- **<big>Frequency</big>** : counts the frequency of each element in the slice.
|
- **<big>Frequency</big>** : counts the frequency of each element in the slice.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#Frequency)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#Frequency)]
|
||||||
[[play](https://go.dev/play/p/CW3UVNdUZOq)]
|
[[play](https://go.dev/play/p/CW3UVNdUZOq)]
|
||||||
|
- **<big>JoinFunc</big>** : joins the slice elements into a single string with the given separator.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#JoinFunc)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>ConcatBy</big>** : concats the elements of a slice into a single value using the provided separator and connector function.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#ConcatBy)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="stream"> 19. Stream package implements a sequence of elements supporting sequential and operations. this package is an experiment to explore if stream in go can work as the way java does. its function is very limited. <a href="#index">index</a></h3>
|
<h3 id="stream"> 19. Stream package implements a sequence of elements supporting sequential and operations. this package is an experiment to explore if stream in go can work as the way java does. its function is very limited. <a href="#index">index</a></h3>
|
||||||
|
|
||||||
@@ -1666,6 +1707,12 @@ import "github.com/duke-git/lancet/v2/stream"
|
|||||||
- **<big>ToSlice</big>** : returns the elements in the stream.
|
- **<big>ToSlice</big>** : returns the elements in the stream.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/stream.md#ToSlice)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/stream.md#ToSlice)]
|
||||||
[[play](https://go.dev/play/p/jI6_iZZuVFE)]
|
[[play](https://go.dev/play/p/jI6_iZZuVFE)]
|
||||||
|
- **<big>IndexOf</big>** : returns the index of the first occurrence of the specified element in this stream.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/stream.md#IndexOf)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>LastIndexOf</big>** : returns the index of the last occurrence of the specified element in this stream.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/stream.md#LastIndexOf)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="structs"> 20. Structs package provides several high level functions to manipulate struct, tag, and field. <a href="#index">index</a></h3>
|
<h3 id="structs"> 20. Structs package provides several high level functions to manipulate struct, tag, and field. <a href="#index">index</a></h3>
|
||||||
|
|
||||||
@@ -1847,6 +1894,9 @@ import "github.com/duke-git/lancet/v2/strutil"
|
|||||||
- **<big>RegexMatchAllGroups</big>** : matches all subgroups in a string using a regular expression and returns the result.
|
- **<big>RegexMatchAllGroups</big>** : matches all subgroups in a string using a regular expression and returns the result.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#RegexMatchAllGroups)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#RegexMatchAllGroups)]
|
||||||
[[play](https://go.dev/play/p/JZiu0RXpgN-)]
|
[[play](https://go.dev/play/p/JZiu0RXpgN-)]
|
||||||
|
- **<big>ExtractContent</big>** : extracts the content between the start and end strings in the source string.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#ExtractContent)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
|
|
||||||
<h3 id="system"> 22. System package contain some functions about os, runtime, shell command. <a href="#index">index</a></h3>
|
<h3 id="system"> 22. System package contain some functions about os, runtime, shell command. <a href="#index">index</a></h3>
|
||||||
@@ -2197,6 +2247,9 @@ import "github.com/duke-git/lancet/v2/xerror"
|
|||||||
- **<big>TryUnwrap</big>** : check if err is nil then it returns a valid value. If err is not nil, TryUnwrap panics with err.
|
- **<big>TryUnwrap</big>** : check if err is nil then it returns a valid value. If err is not nil, TryUnwrap panics with err.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/xerror.md#TryUnwrap)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/xerror.md#TryUnwrap)]
|
||||||
[[play](https://go.dev/play/p/acyZVkNZEeW)]
|
[[play](https://go.dev/play/p/acyZVkNZEeW)]
|
||||||
|
- **<big>TryCatch</big>** : simple simulation of Java-style try-catch.
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/xerror.md#TryCatch)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
## How to Contribute
|
## How to Contribute
|
||||||
|
|
||||||
|
|||||||
103
README_zh-CN.md
103
README_zh-CN.md
@@ -4,7 +4,7 @@
|
|||||||
<br/>
|
<br/>
|
||||||
|
|
||||||

|

|
||||||
[](https://github.com/duke-git/lancet/releases)
|
[](https://github.com/duke-git/lancet/releases)
|
||||||
[](https://pkg.go.dev/github.com/duke-git/lancet/v2)
|
[](https://pkg.go.dev/github.com/duke-git/lancet/v2)
|
||||||
[](https://goreportcard.com/report/github.com/duke-git/lancet/v2)
|
[](https://goreportcard.com/report/github.com/duke-git/lancet/v2)
|
||||||
[](https://github.com/duke-git/lancet/actions/workflows/codecov.yml)
|
[](https://github.com/duke-git/lancet/actions/workflows/codecov.yml)
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
go get github.com/duke-git/lancet/v2 //安装v2最新版本v2.x.x
|
go get github.com/duke-git/lancet/v2 //安装v2最新版本v2.x.x
|
||||||
```
|
```
|
||||||
|
|
||||||
2. <b>使用 go1.18 以下版本的用户,必须安装 v1.x.x。目前最新的 v1 版本是 v1.4.4。</b>
|
2. <b>使用 go1.18 以下版本的用户,必须安装 v1.x.x。目前最新的 v1 版本是 v1.4.5。</b>
|
||||||
|
|
||||||
```go
|
```go
|
||||||
go get github.com/duke-git/lancet// 使用go1.18以下版本, 必须安装v1.x.x版本
|
go get github.com/duke-git/lancet// 使用go1.18以下版本, 必须安装v1.x.x版本
|
||||||
@@ -321,13 +321,19 @@ import "github.com/duke-git/lancet/v2/convertor"
|
|||||||
[[play](https://go.dev/play/p/OphmHCN_9u8)]
|
[[play](https://go.dev/play/p/OphmHCN_9u8)]
|
||||||
- **<big>ToStdBase64</big>** : 将值转换为StdBase64编码的字符串。
|
- **<big>ToStdBase64</big>** : 将值转换为StdBase64编码的字符串。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/convertor.md#ToStdBase64)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/convertor.md#ToStdBase64)]
|
||||||
|
[[play](https://go.dev/play/p/_fLJqJD3NMo)]
|
||||||
- **<big>ToUrlBase64</big>** : 将值转换为url Base64编码的字符串。
|
- **<big>ToUrlBase64</big>** : 将值转换为url Base64编码的字符串。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/convertor.md#ToUrlBase64)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/convertor.md#ToUrlBase64)]
|
||||||
|
[[play](https://go.dev/play/p/C_d0GlvEeUR)]
|
||||||
- **<big>ToRawStdBase64</big>** : 将值转换为RawStdBase64编码的字符串。
|
- **<big>ToRawStdBase64</big>** : 将值转换为RawStdBase64编码的字符串。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/convertor.md#ToRawStdBase64)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/convertor.md#ToRawStdBase64)]
|
||||||
|
[[play](https://go.dev/play/p/wSAr3sfkDcv)]
|
||||||
- **<big>ToRawUrlBase64</big>** : 将值转换为RawUrlBase64编码的字符串。
|
- **<big>ToRawUrlBase64</big>** : 将值转换为RawUrlBase64编码的字符串。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/convertor.md#ToRawUrlBase64)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/convertor.md#ToRawUrlBase64)]
|
||||||
|
[[play](https://go.dev/play/p/HwdDPFcza1O)]
|
||||||
|
- **<big>ToBigInt</big>** : 将整数转为*big.Int。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/convertor.md#ToBigInt)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="cryptor"> 6. cryptor 加密包支持数据加密和解密,获取 md5,hash 值。支持 base64, md5, hmac, aes, des, rsa。 <a href="#index">回到目录</a></h3>
|
<h3 id="cryptor"> 6. cryptor 加密包支持数据加密和解密,获取 md5,hash 值。支持 base64, md5, hmac, aes, des, rsa。 <a href="#index">回到目录</a></h3>
|
||||||
|
|
||||||
@@ -477,7 +483,12 @@ import "github.com/duke-git/lancet/v2/cryptor"
|
|||||||
- **<big>RsaDecryptOAEP</big>** : rsa OAEP解密。
|
- **<big>RsaDecryptOAEP</big>** : rsa OAEP解密。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/cryptor.md#RsaDecryptOAEP)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/cryptor.md#RsaDecryptOAEP)]
|
||||||
[[play](https://go.dev/play/p/sSVmkfENKMz)]
|
[[play](https://go.dev/play/p/sSVmkfENKMz)]
|
||||||
|
- **<big>RsaSign</big>** : 应用RSA算法签名数据。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/cryptor.md#RsaSign)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>RsaVerifySign</big>** : 验证数据的签名是否符合RSA算法。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/cryptor.md#RsaVerifySign)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="datetime"> 7. datetime日期时间处理包,格式化日期,比较日期。 <a href="#index">回到目录</a></h3>
|
<h3 id="datetime"> 7. datetime日期时间处理包,格式化日期,比较日期。 <a href="#index">回到目录</a></h3>
|
||||||
|
|
||||||
@@ -622,6 +633,15 @@ import "github.com/duke-git/lancet/v2/datetime"
|
|||||||
- **<big>GenerateDatetimesBetween</big>** : 生成从start到end的所有日期时间的字符串列表。
|
- **<big>GenerateDatetimesBetween</big>** : 生成从start到end的所有日期时间的字符串列表。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#GenerateDatetimesBetween)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#GenerateDatetimesBetween)]
|
||||||
[[play](https://go.dev/play/p/6kHBpAxD9ZC)]
|
[[play](https://go.dev/play/p/6kHBpAxD9ZC)]
|
||||||
|
- **<big>Min</big>** : 返回最早时间。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#Min)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>Max</big>** : 返回最晚时间。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#Max)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>MaxMin</big>** : 返回最早和最晚时间。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#MaxMin)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
|
|
||||||
<h3 id="datastructure"> 8. datastructure 包含一些普通的数据结构实现。例如:list, linklist, stack, queue, set, tree, graph。 <a href="#index">回到目录</a></h3>
|
<h3 id="datastructure"> 8. datastructure 包含一些普通的数据结构实现。例如:list, linklist, stack, queue, set, tree, graph。 <a href="#index">回到目录</a></h3>
|
||||||
@@ -754,7 +774,9 @@ import "github.com/duke-git/lancet/v2/fileutil"
|
|||||||
- **<big>ParallelChunkRead</big>** : 并行读取文件并将每个块的行发送到指定通道。
|
- **<big>ParallelChunkRead</big>** : 并行读取文件并将每个块的行发送到指定通道。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/fileutil.md#ParallelChunkRead)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/fileutil.md#ParallelChunkRead)]
|
||||||
[[play](https://go.dev/play/p/teMXnCsdSEw)]
|
[[play](https://go.dev/play/p/teMXnCsdSEw)]
|
||||||
|
- **<big>GetExeOrDllVersion</big>** : 返回exe,dll文件版本号(仅Window平台)。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/fileutil.md#GetExeOrDllVersion)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
|
|
||||||
<h3 id="formatter"> 10. formatter 格式化器包含一些数据格式化处理方法。 <a href="#index">回到目录</a></h3>
|
<h3 id="formatter"> 10. formatter 格式化器包含一些数据格式化处理方法。 <a href="#index">回到目录</a></h3>
|
||||||
@@ -1121,7 +1143,18 @@ import "github.com/duke-git/lancet/v2/mathutil"
|
|||||||
- **<big>Div</big>** : 除法运算。
|
- **<big>Div</big>** : 除法运算。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/mathutil.md#Div)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/mathutil.md#Div)]
|
||||||
[[play](https://go.dev/play/p/WLxDdGXXYat)]
|
[[play](https://go.dev/play/p/WLxDdGXXYat)]
|
||||||
|
- **<big>Variance</big>** : 计算方差。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/mathutil.md#Variance)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>StdDev</big>** : 计算标准差。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/mathutil.md#StdDev)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>Permutation</big>** : 计算排列数P(n, k)。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/mathutil.md#Permutation)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>Combination</big>** : 计算组合数C(n, k)。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/mathutil.md#Combination)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="netutil"> 14. netutil 网络包支持获取 ip 地址,发送 http 请求。 <a href="#index">回到目录</a></h3>
|
<h3 id="netutil"> 14. netutil 网络包支持获取 ip 地址,发送 http 请求。 <a href="#index">回到目录</a></h3>
|
||||||
|
|
||||||
@@ -1282,7 +1315,9 @@ import "github.com/duke-git/lancet/v2/random"
|
|||||||
- **<big>RandSliceFromGivenSlice</big>** : 从给定切片中生成长度为 num 的随机切片。
|
- **<big>RandSliceFromGivenSlice</big>** : 从给定切片中生成长度为 num 的随机切片。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandSliceFromGivenSlice)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandSliceFromGivenSlice)]
|
||||||
[[play](https://go.dev/play/p/68UikN9d6VT)]
|
[[play](https://go.dev/play/p/68UikN9d6VT)]
|
||||||
|
- **<big>RandNumberOfLength</big>** : 生成指定长度的随机数。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandNumberOfLength)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="retry"> 17. retry 重试执行函数直到函数运行成功或被 context cancel。 <a href="#index">回到目录</a></h3>
|
<h3 id="retry"> 17. retry 重试执行函数直到函数运行成功或被 context cancel。 <a href="#index">回到目录</a></h3>
|
||||||
|
|
||||||
@@ -1301,7 +1336,7 @@ import "github.com/duke-git/lancet/v2/retry"
|
|||||||
- **<big>RetryFunc</big>** : 重试执行的函数。
|
- **<big>RetryFunc</big>** : 重试执行的函数。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/retry.md#RetryFunc)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/retry.md#RetryFunc)]
|
||||||
[[play](https://go.dev/play/p/nk2XRmagfVF)]
|
[[play](https://go.dev/play/p/nk2XRmagfVF)]
|
||||||
- **<big>RetryTimes</big>** : 设置重试次数,默认 5。
|
- **<big>RetryTimes</big>** : 设置重试次数,默认5。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/retry.md#RetryTimes)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/retry.md#RetryTimes)]
|
||||||
[[play](https://go.dev/play/p/ssfVeU2SwLO)]
|
[[play](https://go.dev/play/p/ssfVeU2SwLO)]
|
||||||
- **<big>BackoffStrategy</big>** : 定义计算退避间隔的方法的接口。
|
- **<big>BackoffStrategy</big>** : 定义计算退避间隔的方法的接口。
|
||||||
@@ -1573,7 +1608,12 @@ import "github.com/duke-git/lancet/v2/slice"
|
|||||||
- **<big>Frequency</big>** : 计算切片中每个元素出现的频率。
|
- **<big>Frequency</big>** : 计算切片中每个元素出现的频率。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#Frequency)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#Frequency)]
|
||||||
[[play](https://go.dev/play/p/CW3UVNdUZOq)]
|
[[play](https://go.dev/play/p/CW3UVNdUZOq)]
|
||||||
|
- **<big>JoinFunc</big>** : 将切片元素用给定的分隔符连接成一个单一的字符串。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#JoinFunc)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>ConcatBy</big>** : 将切片中的元素连接成一个值,使用指定的分隔符和连接器函数。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#ConcatBy)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="stream"> 19. stream 流,该包仅验证简单的 stream 实现,功能有限。 <a href="#index">回到目录</a></h3>
|
<h3 id="stream"> 19. stream 流,该包仅验证简单的 stream 实现,功能有限。 <a href="#index">回到目录</a></h3>
|
||||||
|
|
||||||
@@ -1664,7 +1704,12 @@ import "github.com/duke-git/lancet/v2/stream"
|
|||||||
- **<big>ToSlice</big>** : 返回 stream 中的元素切片。
|
- **<big>ToSlice</big>** : 返回 stream 中的元素切片。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/stream.md#ToSlice)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/stream.md#ToSlice)]
|
||||||
[[play](https://go.dev/play/p/jI6_iZZuVFE)]
|
[[play](https://go.dev/play/p/jI6_iZZuVFE)]
|
||||||
|
- **<big>IndexOf</big>** : 返回在stream中找到值的第一个匹配项的索引,如果找不到值,则返回-1。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/stream.md#IndexOf)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
- **<big>LastIndexOf</big>** : 返回在stream中找到值的最后一个匹配项的索引,如果找不到值,则返回-1。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/stream.md#LastIndexOf)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="structs"> 20. structs 提供操作 struct, tag, field 的相关函数。 <a href="#index">回到目录</a></h3>
|
<h3 id="structs"> 20. structs 提供操作 struct, tag, field 的相关函数。 <a href="#index">回到目录</a></h3>
|
||||||
|
|
||||||
@@ -1849,6 +1894,9 @@ import "github.com/duke-git/lancet/v2/strutil"
|
|||||||
- **<big>RegexMatchAllGroups</big>** : 使用正则表达式匹配字符串中的所有子组并返回结果。
|
- **<big>RegexMatchAllGroups</big>** : 使用正则表达式匹配字符串中的所有子组并返回结果。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#RegexMatchAllGroups)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#RegexMatchAllGroups)]
|
||||||
[[play](https://go.dev/play/p/JZiu0RXpgN-)]
|
[[play](https://go.dev/play/p/JZiu0RXpgN-)]
|
||||||
|
- **<big>ExtractContent</big>** : 提取两个标记之间的内容。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#ExtractContent)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
<h3 id="system"> 22. system 包含 os, runtime, shell command 的相关函数。 <a href="#index">回到目录</a></h3>
|
<h3 id="system"> 22. system 包含 os, runtime, shell command 的相关函数。 <a href="#index">回到目录</a></h3>
|
||||||
|
|
||||||
@@ -2061,7 +2109,7 @@ import "github.com/duke-git/lancet/v2/validator"
|
|||||||
- **<big>IsCreditCard</big>** : 验证字符串是否是信用卡号码。
|
- **<big>IsCreditCard</big>** : 验证字符串是否是信用卡号码。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsCreditCard)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsCreditCard)]
|
||||||
[[play](https://go.dev/play/p/sNwwL6B0-v4)]
|
[[play](https://go.dev/play/p/sNwwL6B0-v4)]
|
||||||
- **<big>IsDns</big>** : 验证字符串是否是有效 dns。
|
- **<big>IsDns</big>** : 验证字符串是否是有效dns。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsDns)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsDns)]
|
||||||
[[play](https://go.dev/play/p/jlYApVLLGTZ)]
|
[[play](https://go.dev/play/p/jlYApVLLGTZ)]
|
||||||
- **<big>IsEmail</big>** : 验证字符串是否是有效电子邮件地址。
|
- **<big>IsEmail</big>** : 验证字符串是否是有效电子邮件地址。
|
||||||
@@ -2097,10 +2145,10 @@ import "github.com/duke-git/lancet/v2/validator"
|
|||||||
- **<big>IsIp</big>** : 验证字符串是否是 ip 地址。
|
- **<big>IsIp</big>** : 验证字符串是否是 ip 地址。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsIp)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsIp)]
|
||||||
[[play](https://go.dev/play/p/FgcplDvmxoD)]
|
[[play](https://go.dev/play/p/FgcplDvmxoD)]
|
||||||
- **<big>IsIpV4</big>** : 验证字符串是否是 ipv4 地址。
|
- **<big>IsIpV4</big>** : 验证字符串是否是ipv4地址。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsIpV4)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsIpV4)]
|
||||||
[[play](https://go.dev/play/p/zBGT99EjaIu)]
|
[[play](https://go.dev/play/p/zBGT99EjaIu)]
|
||||||
- **<big>IsIpV6</big>** : 验证字符串是否是 ipv6 地址。
|
- **<big>IsIpV6</big>** : 验证字符串是否是ipv6地址。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsIpV6)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsIpV6)]
|
||||||
[[play](https://go.dev/play/p/AHA0r0AzIdC)]
|
[[play](https://go.dev/play/p/AHA0r0AzIdC)]
|
||||||
- **<big>IsStrongPassword</big>** : 验证字符串是否是强密码:(字母+数字+特殊字符)。
|
- **<big>IsStrongPassword</big>** : 验证字符串是否是强密码:(字母+数字+特殊字符)。
|
||||||
@@ -2115,10 +2163,10 @@ import "github.com/duke-git/lancet/v2/validator"
|
|||||||
- **<big>IsZeroValue</big>** : 判断传入的参数值是否为零值。
|
- **<big>IsZeroValue</big>** : 判断传入的参数值是否为零值。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsZeroValue)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsZeroValue)]
|
||||||
[[play](https://go.dev/play/p/UMrwaDCi_t4)]
|
[[play](https://go.dev/play/p/UMrwaDCi_t4)]
|
||||||
- **<big>IsGBK</big>** : 检查数据编码是否为 gbk(汉字内部代码扩展规范)。
|
- **<big>IsGBK</big>** : 检查数据编码是否为gbk(汉字内部代码扩展规范)。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsGBK)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsGBK)]
|
||||||
[[play](https://go.dev/play/p/E2nt3unlmzP)]
|
[[play](https://go.dev/play/p/E2nt3unlmzP)]
|
||||||
- **<big>IsASCII</big>** : 验证字符串全部为 ASCII 字符。
|
- **<big>IsASCII</big>** : 验证字符串全部为ASCII字符。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsASCII)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsASCII)]
|
||||||
[[play](https://go.dev/play/p/hfQNPLX0jNa)]
|
[[play](https://go.dev/play/p/hfQNPLX0jNa)]
|
||||||
- **<big>IsPrintable</big>** : 检查字符串是否全部为可打印字符。
|
- **<big>IsPrintable</big>** : 检查字符串是否全部为可打印字符。
|
||||||
@@ -2133,13 +2181,13 @@ import "github.com/duke-git/lancet/v2/validator"
|
|||||||
- **<big>IsBase64URL</big>** : 检查字符串是否是有效的 base64 url。
|
- **<big>IsBase64URL</big>** : 检查字符串是否是有效的 base64 url。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsBase64URL)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsBase64URL)]
|
||||||
[[play](https://go.dev/play/p/vhl4mr8GZ6S)]
|
[[play](https://go.dev/play/p/vhl4mr8GZ6S)]
|
||||||
- **<big>IsJWT</big>** : 检查字符串是否是有效的 JSON Web Token (JWT)。
|
- **<big>IsJWT</big>** : 检查字符串是否是有效的JSON Web Token (JWT)。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsJWT)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsJWT)]
|
||||||
[[play](https://go.dev/play/p/R6Op7heJbKI)]
|
[[play](https://go.dev/play/p/R6Op7heJbKI)]
|
||||||
- **<big>IsVisa</big>** : 检查字符串是否是有效的 visa 卡号。
|
- **<big>IsVisa</big>** : 检查字符串是否是有效的visa卡号。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsVisa)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsVisa)]
|
||||||
[[play](https://go.dev/play/p/SdS2keOyJsl)]
|
[[play](https://go.dev/play/p/SdS2keOyJsl)]
|
||||||
- **<big>IsMasterCard</big>** : 检查字符串是否是有效的 MasterCard 卡号。
|
- **<big>IsMasterCard</big>** : 检查字符串是否是有效的MasterCard卡号。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsMasterCard)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/validator.md#IsMasterCard)]
|
||||||
[[play](https://go.dev/play/p/CwWBFRrG27b)]
|
[[play](https://go.dev/play/p/CwWBFRrG27b)]
|
||||||
- **<big>IsAmericanExpress</big>** : 检查字符串是否是有效的 American Express 卡号。
|
- **<big>IsAmericanExpress</big>** : 检查字符串是否是有效的 American Express 卡号。
|
||||||
@@ -2175,30 +2223,33 @@ import "github.com/duke-git/lancet/v2/xerror"
|
|||||||
- **<big>XError_Unwrap</big>** : 解构 XEerror 为 error 对象。适配 github.com/pkg/errors。
|
- **<big>XError_Unwrap</big>** : 解构 XEerror 为 error 对象。适配 github.com/pkg/errors。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_Unwrap)
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_Unwrap)
|
||||||
[[play](https://go.dev/play/p/VUXJ8BST4c6)]
|
[[play](https://go.dev/play/p/VUXJ8BST4c6)]
|
||||||
- **<big>XError_With</big>** : 添加与 XError 对象的键和值。
|
- **<big>XError_With</big>** : 添加与XError对象的键和值。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_With)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_With)]
|
||||||
[[play](https://go.dev/play/p/ow8UISXX_Dp)]
|
[[play](https://go.dev/play/p/ow8UISXX_Dp)]
|
||||||
- **<big>XError_Id</big>** : 设置 XError 对象的 id。
|
- **<big>XError_Id</big>** : 设置XError对象的id。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_Id)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_Id)]
|
||||||
[[play](https://go.dev/play/p/X6HBlsy58U9)]
|
[[play](https://go.dev/play/p/X6HBlsy58U9)]
|
||||||
- **<big>XError_Is</big>** : 检查目标 error 是否为 XError,两个错误中的 error.id 是否匹配。
|
- **<big>XError_Is</big>** : 检查目标error是否为XError,两个错误中的error.id是否匹配。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_Is)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_Is)]
|
||||||
[[play](https://go.dev/play/p/X6HBlsy58U9)]
|
[[play](https://go.dev/play/p/X6HBlsy58U9)]
|
||||||
- **<big>XError_Values</big>** : 返回由 With 设置的键和值的映射。将合并所有 XError 键和值。
|
- **<big>XError_Values</big>** : 返回由With设置的键和值的映射。将合并所有XError键和值。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_Values)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_Values)]
|
||||||
[[play](https://go.dev/play/p/ow8UISXX_Dp)]
|
[[play](https://go.dev/play/p/ow8UISXX_Dp)]
|
||||||
- **<big>XError_StackTrace</big>** : 返回与 pkg/error 兼容的堆栈信息。
|
- **<big>XError_StackTrace</big>** : 返回与pkg/error兼容的堆栈信息。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_StackTrace)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_StackTrace)]
|
||||||
[[play](https://go.dev/play/p/6FAvSQpa7pc)]
|
[[play](https://go.dev/play/p/6FAvSQpa7pc)]
|
||||||
- **<big>XError_Info</big>** : 返回可打印的 XError 对象信息。
|
- **<big>XError_Info</big>** : 返回可打印的XError对象信息。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_Info)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_Info)]
|
||||||
[[play](https://go.dev/play/p/1ZX0ME1F-Jb)]
|
[[play](https://go.dev/play/p/1ZX0ME1F-Jb)]
|
||||||
- **<big>XError_Error</big>** : 实现标准库的 error 接口。
|
- **<big>XError_Error</big>** : 实现标准库的error接口。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_Error)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#XError_Error)]
|
||||||
[[play](https://go.dev/play/p/w4oWZts7q7f)]
|
[[play](https://go.dev/play/p/w4oWZts7q7f)]
|
||||||
- **<big>TryUnwrap</big>** : 检查 error, 如果 err 为 nil 则展开,则它返回一个有效值,如果 err 不是 nil 则 Unwrap 使用 err 发生 panic。
|
- **<big>TryUnwrap</big>** : 检查error, 如果err为nil则展开,则它返回一个有效值,如果err不是nil则Unwrap使用err发生panic。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#TryUnwrap)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#TryUnwrap)]
|
||||||
[[play](https://go.dev/play/p/acyZVkNZEeW)]
|
[[play](https://go.dev/play/p/acyZVkNZEeW)]
|
||||||
|
- **<big>TryCatch</big>** : 简单实现的java风格异常处理(try-catch-finally)。
|
||||||
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#TryCatch)]
|
||||||
|
[[play](https://go.dev/play/p/todo)]
|
||||||
|
|
||||||
## 如何贡献代码
|
## 如何贡献代码
|
||||||
|
|
||||||
|
|||||||
@@ -100,12 +100,6 @@ func TestBSTree_Delete(t *testing.T) {
|
|||||||
|
|
||||||
acturl1 := bstree.InOrderTraverse()
|
acturl1 := bstree.InOrderTraverse()
|
||||||
assert.Equal([]int{2, 5, 6, 7}, acturl1)
|
assert.Equal([]int{2, 5, 6, 7}, acturl1)
|
||||||
|
|
||||||
//todo
|
|
||||||
// bstree.DeletetNode(6, comparator)
|
|
||||||
// bstree.Print()
|
|
||||||
// acturl2 := bstree.InOrderTraverse()
|
|
||||||
// assert.Equal([]int{2, 5, 7}, acturl2)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBSTree_Depth(t *testing.T) {
|
func TestBSTree_Depth(t *testing.T) {
|
||||||
|
|||||||
@@ -1236,7 +1236,7 @@ func main() {
|
|||||||
|
|
||||||
### <span id="Permutation">Permutation</span>
|
### <span id="Permutation">Permutation</span>
|
||||||
|
|
||||||
<p>计算排列数(P(n, k))。</p>
|
<p>计算排列数P(n, k)。</p>
|
||||||
|
|
||||||
<b>函数签名:</b>
|
<b>函数签名:</b>
|
||||||
|
|
||||||
@@ -1269,7 +1269,7 @@ func main() {
|
|||||||
|
|
||||||
### <span id="Combination">Combination</span>
|
### <span id="Combination">Combination</span>
|
||||||
|
|
||||||
<p>计算组合数(C(n, k))。</p>
|
<p>计算组合数C(n, k)。</p>
|
||||||
|
|
||||||
<b>函数签名:</b>
|
<b>函数签名:</b>
|
||||||
|
|
||||||
|
|||||||
@@ -526,7 +526,7 @@ func main() {
|
|||||||
```
|
```
|
||||||
### <span id="RandNumberOfLength">RandNumberOfLength</span>
|
### <span id="RandNumberOfLength">RandNumberOfLength</span>
|
||||||
|
|
||||||
<p>生成指定长度的随机数</p>
|
<p>生成指定长度的随机数。</p>
|
||||||
|
|
||||||
<b>函数签名:</b>
|
<b>函数签名:</b>
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ outline: deep
|
|||||||
go get github.com/duke-git/lancet/v2 // will install latest version of v2.x.x
|
go get github.com/duke-git/lancet/v2 // will install latest version of v2.x.x
|
||||||
```
|
```
|
||||||
|
|
||||||
2. <b>For users who use version below go1.18, you should install v1.x.x. The latest of v1.x.x is v1.4.4. </b>
|
2. <b>For users who use version below go1.18, you should install v1.x.x. The latest of v1.x.x is v1.4.5. </b>
|
||||||
|
|
||||||
```go
|
```go
|
||||||
go get github.com/duke-git/lancet // below go1.18, install latest version of v1.x.x
|
go get github.com/duke-git/lancet // below go1.18, install latest version of v1.x.x
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ outline: deep
|
|||||||
go get github.com/duke-git/lancet/v2 // will install latest version of v2.x.x
|
go get github.com/duke-git/lancet/v2 // will install latest version of v2.x.x
|
||||||
```
|
```
|
||||||
|
|
||||||
2. <b>使用 go1.18 以下版本的用户,必须安装 v1.x.x。目前最新的 v1 版本是 v1.4.4。</b>
|
2. <b>使用 go1.18 以下版本的用户,必须安装 v1.x.x。目前最新的 v1 版本是 v1.4.5。</b>
|
||||||
|
|
||||||
```go
|
```go
|
||||||
go get github.com/duke-git/lancet // below go1.18, install latest version of v1.x.x
|
go get github.com/duke-git/lancet // below go1.18, install latest version of v1.x.x
|
||||||
|
|||||||
Reference in New Issue
Block a user