mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-23 13:52:26 +08:00
Compare commits
3 Commits
f03f48210c
...
ffe46fd06d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffe46fd06d | ||
|
|
b419e46b9b | ||
|
|
8fbcdfd515 |
181
README.md
181
README.md
@@ -24,7 +24,7 @@ English | [简体中文](./README_zh-CN.md)
|
||||
## Feature
|
||||
|
||||
- 👏 Comprehensive, efficient and reusable.
|
||||
- 💪 500+ go util functions, support string, slice, datetime, net, crypt...
|
||||
- 💪 600+ go util functions, support string, slice, datetime, net, crypt...
|
||||
- 💅 Only depends on two kinds of libraries: go standard library and golang.org/x.
|
||||
- 🌍 Unit test for every exported function.
|
||||
|
||||
@@ -73,7 +73,36 @@ func main() {
|
||||
|
||||
## Documentation
|
||||
|
||||
### 1. Algorithm package implements some basic algorithm. eg. sort, search.
|
||||
### <span id="index">Index<span>
|
||||
|
||||
- [Algorithm](#Algorithm)
|
||||
- [Compare](#Compare)
|
||||
- [Concurrency](#Concurrency)
|
||||
- [Condition](#Condition)
|
||||
- [Convertor](#Convertor)
|
||||
- [Cryptor](#Cryptor)
|
||||
- [Datetime](#Datetime)
|
||||
- [Datastructure](#Datastructure)
|
||||
- [Fileutil](#Fileutil)
|
||||
- [Formatter](#Formatter)
|
||||
- [Function](#Function)
|
||||
- [Iterator](#Iterator)
|
||||
- [Maputil](#Maputil)
|
||||
- [Mathutil](#Mathutil)
|
||||
- [Netutil](#Netutil)
|
||||
- [Pointer](#Pointer)
|
||||
- [Random](#Random)
|
||||
- [Retry](#Retry)
|
||||
- [Slice](#Slice)
|
||||
- [Stream](#Stream)
|
||||
- [Structs](#Structs)
|
||||
- [Strutil](#Strutil)
|
||||
- [System](#System)
|
||||
- [Tuple](#Tuple)
|
||||
- [Validator](#Validator)
|
||||
- [Xerror](#Xerror)
|
||||
|
||||
### <span id="Algorithm">1. Algorithm package implements some basic algorithm. eg. sort, search.</span></span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/algorithm"
|
||||
@@ -118,7 +147,7 @@ import "github.com/duke-git/lancet/v2/algorithm"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/algorithm.md#LRUCache)]
|
||||
[[play](https://go.dev/play/p/-EZjgOURufP)]
|
||||
|
||||
### 2. Compare package provides a lightweight comparison function on any type.
|
||||
### <span id="Compare">2. Compare package provides a lightweight comparison function on any type.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/compare"
|
||||
@@ -145,7 +174,7 @@ import "github.com/duke-git/lancet/v2/compare"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare.md#GreaterOrEqual)]
|
||||
[[play](https://go.dev/play/p/vx8mP0U8DFk)]
|
||||
|
||||
### 3. Concurrency package contain some functions to support concurrent programming. eg, goroutine, channel, async.
|
||||
### <span id="Concurrency">3. Concurrency package contain some functions to support concurrent programming. eg, goroutine, channel, async.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/concurrency"
|
||||
@@ -184,7 +213,7 @@ import "github.com/duke-git/lancet/v2/concurrency"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/concurrency.md#Tee)]
|
||||
[[play](https://go.dev/play/p/3TQPKnCirrP)]
|
||||
|
||||
### 4. Condition package contains some functions for conditional judgment. eg. And, Or, TernaryOperator...
|
||||
### <span id="Condition">4. Condition package contains some functions for conditional judgment. eg. And, Or, TernaryOperator...</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/condition"
|
||||
@@ -217,7 +246,7 @@ import "github.com/duke-git/lancet/v2/condition"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/condition.md#TernaryOperator)]
|
||||
[[play](https://go.dev/play/p/ElllPZY0guT)]
|
||||
|
||||
### 5. Convertor package contains some functions for data convertion.
|
||||
### <span id="Convertor">5. Convertor package contains some functions for data convertion.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/convertor"
|
||||
@@ -289,8 +318,7 @@ import "github.com/duke-git/lancet/v2/convertor"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#GbkToUtf8)]
|
||||
[[play](https://go.dev/play/p/OphmHCN_9u8)]
|
||||
|
||||
|
||||
### 6. Cryptor package is for data encryption and decryption.
|
||||
### <span id="Cryptor">6. Cryptor package is for data encryption and decryption.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/cryptor"
|
||||
@@ -394,7 +422,7 @@ import "github.com/duke-git/lancet/v2/cryptor"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor.md#RsaDecrypt)]
|
||||
[[play](https://go.dev/play/p/uef0q1fz53I)]
|
||||
|
||||
### 7. Datetime package supports date and time format and compare.
|
||||
### <span id="Datetime">7. Datetime package supports date and time format and compare.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/datetime"
|
||||
@@ -508,8 +536,7 @@ import "github.com/duke-git/lancet/v2/datetime"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime.md#IsWeekend)]
|
||||
[[play](https://go.dev/play/p/cupRM5aZOIY)]
|
||||
|
||||
|
||||
### 8. Datastructure package constains some common data structure. eg. list, linklist, stack, queue, set, tree, graph.
|
||||
### <span id="Datastructure">8. Datastructure package constains some common data structure. eg. list, linklist, stack, queue, set, tree, graph.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import list "github.com/duke-git/lancet/v2/datastructure/list"
|
||||
@@ -541,7 +568,7 @@ import hashmap "github.com/duke-git/lancet/v2/datastructure/hashmap"
|
||||
- **<big>Hashmap</big>** : hash map structure.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/datastructure/hashmap.md)]
|
||||
|
||||
### 9. Fileutil package implements some basic functions for file operations.
|
||||
### <span id="Fileutil">9. Fileutil package implements some basic functions for file operations.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/fileutil"
|
||||
@@ -624,8 +651,7 @@ import "github.com/duke-git/lancet/v2/fileutil"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil.md#WriteStringToFile)]
|
||||
[[play](https://go.dev/play/p/GhLS6d8lH_g)]
|
||||
|
||||
|
||||
### 10. Formatter contains some functions for data formatting.
|
||||
### <span id="Formatter">10. Formatter contains some functions for data formatting.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/formatter"
|
||||
@@ -655,7 +681,7 @@ import "github.com/duke-git/lancet/v2/formatter"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter.md#ParseBinaryBytes)]
|
||||
[[play](https://go.dev/play/p/69v1tTT62x8)]
|
||||
|
||||
### 11. Function package can control the flow of function execution and support part of functional programming
|
||||
### <span id="Function">11. Function package can control the flow of function execution and support part of functional programming.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/function"
|
||||
@@ -691,7 +717,7 @@ import "github.com/duke-git/lancet/v2/function"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/function.md#Watcher)]
|
||||
[[play](https://go.dev/play/p/l2yrOpCLd1I)]
|
||||
|
||||
### 12. Maputil package includes some functions to manipulate map.
|
||||
### <span id="Maputil">12. Maputil package includes some functions to manipulate map.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/maputil"
|
||||
@@ -763,7 +789,7 @@ import "github.com/duke-git/lancet/v2/maputil"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil.md#IsDisjoint)]
|
||||
[[play](https://go.dev/play/p/N9qgYg_Ho6f)]
|
||||
|
||||
### 13. Mathutil package implements some functions for math calculation.
|
||||
### <span id="Mathutil">13. Mathutil package implements some functions for math calculation.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/mathutil"
|
||||
@@ -844,8 +870,7 @@ import "github.com/duke-git/lancet/v2/mathutil"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#Sum)]
|
||||
[[play](https://go.dev/play/p/1To2ImAMJA7)]
|
||||
|
||||
|
||||
### 14. Netutil package contains functions to get net information and send http request.
|
||||
### <span id="Netutil">14. Netutil package contains functions to get net information and send http request.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/netutil"
|
||||
@@ -918,7 +943,25 @@ import "github.com/duke-git/lancet/v2/netutil"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/netutil.md#IsTelnetConnected)]
|
||||
[[play](https://go.dev/play/p/yiLCGtQv_ZG)]
|
||||
|
||||
### 15. Random package implements some basic functions to generate random int and string.
|
||||
### <span id="Pointer">15. Pointer package contains some util functions to operate go pointer.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/pointer"
|
||||
```
|
||||
|
||||
#### Function list:
|
||||
|
||||
- **<big>ExtractPointer</big>** : return the underlying value by the given interface type.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/pointer.md#ExtractPointer)]
|
||||
[[play](https://go.dev/play/p/D7HFjeWU2ZP)]
|
||||
- **<big>Of</big>** : return a pointer to the value `v`.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/pointer.md#Of)]
|
||||
[[play](https://go.dev/play/p/HFd70x4DrMj)]
|
||||
- **<big>Unwrap</big>** : return the value from the pointer.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/pointer.md#Unwrap)]
|
||||
[[play](https://go.dev/play/p/cgeu3g7cjWb)]
|
||||
|
||||
### <span id="Random">16. Random package implements some basic functions to generate random int and string.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/random"
|
||||
@@ -954,8 +997,7 @@ import "github.com/duke-git/lancet/v2/random"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/random.md#RandUniqueIntSlice)]
|
||||
[[play](https://go.dev/play/p/uBkRSOz73Ec)]
|
||||
|
||||
|
||||
### 16. Retry package is for executing a function repeatedly until it was successful or canceled by the context.
|
||||
### <span id="Retry">17. Retry package is for executing a function repeatedly until it was successful or canceled by the context.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/retry"
|
||||
@@ -979,7 +1021,7 @@ import "github.com/duke-git/lancet/v2/retry"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/retry.md#RetryTimes)]
|
||||
[[play](https://go.dev/play/p/ssfVeU2SwLO)]
|
||||
|
||||
### 17. Slice contains some functions to manipulate slice.
|
||||
### <span id="Slice">18. Slice contains some functions to manipulate slice.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/slice"
|
||||
@@ -1192,7 +1234,7 @@ import "github.com/duke-git/lancet/v2/slice"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/slice.md#KeyBy)]
|
||||
[[play](https://go.dev/play/p/uXod2LWD1Kg)]
|
||||
|
||||
### 18. 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.
|
||||
### <span 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.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/stream"
|
||||
@@ -1279,7 +1321,7 @@ import "github.com/duke-git/lancet/v2/stream"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/stream.md#ToSlice)]
|
||||
[[play](https://go.dev/play/p/jI6_iZZuVFE)]
|
||||
|
||||
### 19. Structs package provides several high level functions to manipulate struct, tag, and field.
|
||||
### <span id="Structs">20. Structs package provides several high level functions to manipulate struct, tag, and field.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/structs"
|
||||
@@ -1312,7 +1354,7 @@ import "github.com/duke-git/lancet/v2/structs"
|
||||
- **<big>IsSlice</big>** : check if the field is a slice
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/structs/field.md#IsSlice)]
|
||||
|
||||
### 20. Strutil package contains some functions to manipulate string.
|
||||
### <span id="Strutil">21. Strutil package contains some functions to manipulate string.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/strutil"
|
||||
@@ -1430,7 +1472,7 @@ import "github.com/duke-git/lancet/v2/strutil"
|
||||
- **<big>RemoveWhiteSpace</big>** : remove whitespace characters from a string.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#RemoveWhiteSpace)]
|
||||
|
||||
### 21. System package contain some functions about os, runtime, shell command.
|
||||
### <span id="System">22. System package contain some functions about os, runtime, shell command.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/system"
|
||||
@@ -1466,7 +1508,88 @@ import "github.com/duke-git/lancet/v2/system"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/system.md#GetOsBits)]
|
||||
[[play](https://go.dev/play/p/ml-_XH3gJbW)]
|
||||
|
||||
### 22. Validator package contains some functions for data validation.
|
||||
### <span id="Tuple">23. Tuple package implements tuple data type and some operations on it.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/tuple"
|
||||
```
|
||||
|
||||
#### Function list:
|
||||
|
||||
- **<big>Tuple2</big>** : represents a 2 elemnets tuple.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple2)]
|
||||
- **<big>Tuple2_Unbox</big>** : returns values in Tuple2.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple2_Unbox)]
|
||||
- **<big>Zip2</big>** : create a slice of Tuple2, whose elements are correspond to the given slice elements.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Zip2)]
|
||||
- **<big>Unzip2</big>** : create a group of slice from a slice of Tuple2.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Unzip2)]
|
||||
- **<big>Tuple3</big>** : represents a 3 elemnets tuple.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple3)]
|
||||
- **<big>Tuple3_Unbox</big>** : returns values in Tuple3.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple3_Unbox)]
|
||||
- **<big>Zip3</big>** : create a slice of Tuple3, whose elements are correspond to the given slice elements.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Zip3)]
|
||||
- **<big>Unzip3</big>** : create a group of slice from a slice of Tuple3.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Unzip3)]
|
||||
- **<big>Tuple4</big>** : represents a 4 elemnets tuple.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple4)]
|
||||
- **<big>Tuple4_Unbox</big>** : returns values in Tuple4.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple4_Unbox)]
|
||||
- **<big>Zip4</big>** : create a slice of Tuple4, whose elements are correspond to the given slice elements.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Zip4)]
|
||||
- **<big>Unzip4</big>** : create a group of slice from a slice of Tuple4.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Unzip4)]
|
||||
- **<big>Tuple5</big>** : represents a 5 elemnets tuple.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple5)]
|
||||
- **<big>Tuple5_Unbox</big>** : returns values in Tuple4.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple5_Unbox)]
|
||||
- **<big>Zip5</big>** : create a slice of Tuple5, whose elements are correspond to the given slice elements.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Zip5)]
|
||||
- **<big>Unzip5</big>** : create a group of slice from a slice of Tuple5.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Unzip5)]
|
||||
- **<big>Tuple6</big>** : represents a 6 elemnets tuple.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple6)]
|
||||
- **<big>Tuple6_Unbox</big>** : returns values in Tuple6.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple6_Unbox)]
|
||||
- **<big>Zip6</big>** : create a slice of Tuple6, whose elements are correspond to the given slice elements.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Zip6)]
|
||||
- **<big>Unzip6</big>** : create a group of slice from a slice of Tuple6.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Unzip6)]
|
||||
- **<big>Tuple7</big>** : represents a 7 elemnets tuple.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple7)]
|
||||
- **<big>Tuple7_Unbox</big>** : returns values in Tuple7.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple7_Unbox)]
|
||||
- **<big>Zip7</big>** : create a slice of Tuple7, whose elements are correspond to the given slice elements.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Zip7)]
|
||||
- **<big>Unzip7</big>** : create a group of slice from a slice of Tuple7.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Unzip7)]
|
||||
- **<big>Tuple8</big>** : represents a 8 elemnets tuple.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple8)]
|
||||
- **<big>Tuple8_Unbox</big>** : returns values in Tuple8.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple8_Unbox)]
|
||||
- **<big>Zip8</big>** : create a slice of Tuple8, whose elements are correspond to the given slice elements.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Zip8)]
|
||||
- **<big>Unzip8</big>** : create a group of slice from a slice of Tuple8.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Unzip8)]
|
||||
- **<big>Tuple9</big>** : represents a 9 elemnets tuple.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple9)]
|
||||
- **<big>Tuple9_Unbox</big>** : returns values in Tuple9.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple9_Unbox)]
|
||||
- **<big>Zip9</big>** : create a slice of Tuple9, whose elements are correspond to the given slice elements.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Zip9)]
|
||||
- **<big>Unzip9</big>** : create a group of slice from a slice of Tuple9.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Unzip9)]
|
||||
- **<big>Tuple10</big>** : represents a 10 elemnets tuple.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple10)]
|
||||
- **<big>Tuple10_Unbox</big>** : returns values in Tuple10.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Tuple10_Unbox)]
|
||||
- **<big>Zip10</big>** : create a slice of Tuple10, whose elements are correspond to the given slice elements.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Zip10)]
|
||||
- **<big>Unzip10</big>** : create a group of slice from a slice of Tuple10.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple.md#Unzip10)]
|
||||
|
||||
### <span id="Validator">24. Validator package contains some functions for data validation.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/validator"
|
||||
@@ -1574,7 +1697,7 @@ import "github.com/duke-git/lancet/v2/validator"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsPrintable)]
|
||||
[[play](https://go.dev/play/p/Pe1FE2gdtTP)]
|
||||
|
||||
### 23. xerror package implements helpers for errors.
|
||||
### <span id="Xerror">25. xerror package implements helpers for errors.</span> [index](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/xerror"
|
||||
|
||||
181
README_zh-CN.md
181
README_zh-CN.md
@@ -23,7 +23,7 @@
|
||||
## 特性
|
||||
|
||||
- 👏 全面、高效、可复用。
|
||||
- 💪 500+常用 go 工具函数,支持 string、slice、datetime、net、crypt...
|
||||
- 💪 600+常用 go 工具函数,支持 string、slice、datetime、net、crypt...
|
||||
- 💅 只依赖 go 标准库和 golang.org/x。
|
||||
- 🌍 所有导出函数单元测试覆盖率 100%。
|
||||
|
||||
@@ -72,7 +72,36 @@ func main() {
|
||||
|
||||
## 文档
|
||||
|
||||
### 1. algorithm 包实现一些基本查找和排序算法。
|
||||
### <span id="index">目录<span>
|
||||
|
||||
- [Algorithm](#Algorithm)
|
||||
- [Compare](#Compare)
|
||||
- [Concurrency](#Concurrency)
|
||||
- [Condition](#Condition)
|
||||
- [Convertor](#Convertor)
|
||||
- [Cryptor](#Cryptor)
|
||||
- [Datetime](#Datetime)
|
||||
- [Datastructure](#Datastructure)
|
||||
- [Fileutil](#Fileutil)
|
||||
- [Formatter](#Formatter)
|
||||
- [Function](#Function)
|
||||
- [Iterator](#Iterator)
|
||||
- [Maputil](#Maputil)
|
||||
- [Mathutil](#Mathutil)
|
||||
- [Netutil](#Netutil)
|
||||
- [Pointer](#Pointer)
|
||||
- [Random](#Random)
|
||||
- [Retry](#Retry)
|
||||
- [Slice](#Slice)
|
||||
- [Stream](#Stream)
|
||||
- [Structs](#Structs)
|
||||
- [Strutil](#Strutil)
|
||||
- [System](#System)
|
||||
- [Tuple](#Tuple)
|
||||
- [Validator](#Validator)
|
||||
- [Xerror](#Xerror)
|
||||
|
||||
### <span id="Algorithm">1. algorithm 包实现一些基本查找和排序算法。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/algorithm"
|
||||
@@ -117,7 +146,7 @@ import "github.com/duke-git/lancet/v2/algorithm"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/algorithm_zh-CN.md#LRUCache)]
|
||||
[[play](https://go.dev/play/p/-EZjgOURufP)]
|
||||
|
||||
### 2. compare 包提供几个轻量级的类型比较函数。
|
||||
### <span id="Compare">2. compare 包提供几个轻量级的类型比较函数。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/compare"
|
||||
@@ -144,7 +173,7 @@ import "github.com/duke-git/lancet/v2/compare"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare_zh-CN.md#GreaterOrEqual)]
|
||||
[[play](https://go.dev/play/p/vx8mP0U8DFk)]
|
||||
|
||||
### 3. concurrency 包含一些支持并发编程的功能。例如:goroutine, channel, async 等。
|
||||
### <span id="Concurrency">3. concurrency 包含一些支持并发编程的功能。例如:goroutine, channel, async 等。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/concurrency"
|
||||
@@ -183,7 +212,7 @@ import "github.com/duke-git/lancet/v2/concurrency"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/concurrency_zh-CN.md#Tee)]
|
||||
[[play](https://go.dev/play/p/3TQPKnCirrP)]
|
||||
|
||||
### 4. condition 包含一些用于条件判断的函数。
|
||||
### <span id="Condition">4. condition 包含一些用于条件判断的函数。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/condition"
|
||||
@@ -216,7 +245,7 @@ import "github.com/duke-git/lancet/v2/condition"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/condition_zh-CN.md#TernaryOperator)]
|
||||
[[play](https://go.dev/play/p/ElllPZY0guT)]
|
||||
|
||||
### 5. convertor 转换器包支持一些常见的数据类型转换。
|
||||
### <span id="Convertor">5. convertor 转换器包支持一些常见的数据类型转换。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/convertor"
|
||||
@@ -288,8 +317,7 @@ import "github.com/duke-git/lancet/v2/convertor"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#GbkToUtf8)]
|
||||
[[play](https://go.dev/play/p/OphmHCN_9u8)]
|
||||
|
||||
|
||||
### 6. cryptor 加密包支持数据加密和解密,获取 md5,hash 值。支持 base64, md5, hmac, aes, des, rsa。
|
||||
### <span id="Cryptor">6. cryptor 加密包支持数据加密和解密,获取 md5,hash 值。支持 base64, md5, hmac, aes, des, rsa。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/cryptor"
|
||||
@@ -393,7 +421,7 @@ import "github.com/duke-git/lancet/v2/cryptor"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/cryptor_zh-CN.md#RsaDecrypt)]
|
||||
[[play](https://go.dev/play/p/uef0q1fz53I)]
|
||||
|
||||
### 7. datetime 日期时间处理包,格式化日期,比较日期。
|
||||
### <span id="Datetime">7. datetime 日期时间处理包,格式化日期,比较日期。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/datetime"
|
||||
@@ -510,7 +538,7 @@ import "github.com/duke-git/lancet/v2/datetime"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime_zh-CN.md#IsWeekend)]
|
||||
[[play](https://go.dev/play/p/cupRM5aZOIY)]
|
||||
|
||||
### 8. datastructure 包含一些普通的数据结构实现。例如:list, linklist, stack, queue, set, tree, graph.
|
||||
### <span id="Datastructure">8. datastructure 包含一些普通的数据结构实现。例如:list, linklist, stack, queue, set, tree, graph.</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import list "github.com/duke-git/lancet/v2/datastructure/list"
|
||||
@@ -542,7 +570,7 @@ import hashmap "github.com/duke-git/lancet/v2/datastructure/hashmap"
|
||||
- **<big>Hashmap</big>** : 哈希映射。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/datastructure/hashmap_zh-CN.md)]
|
||||
|
||||
### 9. fileutil 包含文件基本操作。
|
||||
### <span id="Fileutil">9. fileutil 包含文件基本操作。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/fileutil"
|
||||
@@ -625,7 +653,7 @@ import "github.com/duke-git/lancet/v2/fileutil"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil_zh-CN.md#WriteStringToFile)]
|
||||
[[play](https://go.dev/play/p/GhLS6d8lH_g)]
|
||||
|
||||
### 10. formatter 格式化器包含一些数据格式化处理方法。
|
||||
### <span id="Formatter">10. formatter 格式化器包含一些数据格式化处理方法。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/formatter"
|
||||
@@ -655,7 +683,7 @@ import "github.com/duke-git/lancet/v2/formatter"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/formatter_zh-CN.md#ParseBinaryBytes)]
|
||||
[[play](https://go.dev/play/p/69v1tTT62x8)]
|
||||
|
||||
### 11. function 函数包控制函数执行流程,包含部分函数式编程。
|
||||
### <span id="Function">11. function 函数包控制函数执行流程,包含部分函数式编程。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/function"
|
||||
@@ -691,7 +719,7 @@ import "github.com/duke-git/lancet/v2/function"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/function_zh-CN.md#Watcher)]
|
||||
[[play](https://go.dev/play/p/l2yrOpCLd1I)]
|
||||
|
||||
### 12. maputil 包括一些操作 map 的函数.
|
||||
### <span id="Maputil">12. maputil 包括一些操作 map 的函数.</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/maputil"
|
||||
@@ -763,7 +791,7 @@ import "github.com/duke-git/lancet/v2/maputil"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/maputil_zh-CN.md#IsDisjoint)]
|
||||
[[play](https://go.dev/play/p/N9qgYg_Ho6f)]
|
||||
|
||||
### 13. mathutil 包实现了一些数学计算的函数。
|
||||
### <span id="Mathutil">13. mathutil 包实现了一些数学计算的函数。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/mathutil"
|
||||
@@ -844,8 +872,7 @@ import "github.com/duke-git/lancet/v2/mathutil"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#Sum)]
|
||||
[[play](https://go.dev/play/p/1To2ImAMJA7)]
|
||||
|
||||
|
||||
### 14. netutil 网络包支持获取 ip 地址,发送 http 请求。
|
||||
### <span id="Netutil">14. netutil 网络包支持获取 ip 地址,发送 http 请求。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/netutil"
|
||||
@@ -918,7 +945,25 @@ import "github.com/duke-git/lancet/v2/netutil"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/netutil_zh-CN.md#IsTelnetConnected)]
|
||||
[[play](https://go.dev/play/p/yiLCGtQv_ZG)]
|
||||
|
||||
### 15. random 随机数生成器包,可以生成随机[]bytes, int, string。
|
||||
### <span id="Pointer">15. pointer 包支持一些指针类型的操作。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/pointer"
|
||||
```
|
||||
|
||||
#### 函数列表:
|
||||
|
||||
- **<big>ExtractPointer</big>** : 返回传入 interface 的底层值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/pointer_zh-CN.md#ExtractPointer)]
|
||||
[[play](https://go.dev/play/p/D7HFjeWU2ZP)]
|
||||
- **<big>Of</big>** : 返回传入参数的指针值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/pointer_zh-CN.md#Of)]
|
||||
[[play](https://go.dev/play/p/HFd70x4DrMj)]
|
||||
- **<big>Unwrap</big>** : 返回传入指针指向的值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/pointer_zh-CN.md#Unwrap)]
|
||||
[[play](https://go.dev/play/p/cgeu3g7cjWb)]
|
||||
|
||||
### <span id="Random">16. random 随机数生成器包,可以生成随机[]bytes, int, string。
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/random"
|
||||
@@ -950,12 +995,11 @@ import "github.com/duke-git/lancet/v2/random"
|
||||
- **<big>UUIdV4</big>** : 生成 UUID v4 字符串。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/random_zh-CN.md#UUIdV4)]
|
||||
[[play](https://go.dev/play/p/_Z9SFmr28ft)]
|
||||
- **<big>RandUniqueIntSlice</big>** : 生成一个不重复的长度为n的随机int切片。
|
||||
- **<big>RandUniqueIntSlice</big>** : 生成一个不重复的长度为 n 的随机 int 切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/random_zh-CN.md#RandUniqueIntSlice)]
|
||||
[[play](https://go.dev/play/p/uBkRSOz73Ec)]
|
||||
|
||||
|
||||
### 16. retry 重试执行函数直到函数运行成功或被 context cancel。
|
||||
### <span id="Retry">17. retry 重试执行函数直到函数运行成功或被 context cancel。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/retry"
|
||||
@@ -979,7 +1023,7 @@ import "github.com/duke-git/lancet/v2/retry"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/retry_zh-CN.md#RetryTimes)]
|
||||
[[play](https://go.dev/play/p/ssfVeU2SwLO)]
|
||||
|
||||
### 17. slice 包含操作切片的方法集合。
|
||||
### <span id="Slice">18. slice 包含操作切片的方法集合。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/slice"
|
||||
@@ -1192,7 +1236,7 @@ import "github.com/duke-git/lancet/v2/slice"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/slice_zh-CN.md#KeyBy)]
|
||||
[[play](https://go.dev/play/p/uXod2LWD1Kg)]
|
||||
|
||||
### 18. Stream 流,该包仅验证简单的 stream 实现,功能有限。
|
||||
### <span id="Stream">19. stream 流,该包仅验证简单的 stream 实现,功能有限。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/stream"
|
||||
@@ -1279,7 +1323,7 @@ import "github.com/duke-git/lancet/v2/stream"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/stream_zh-CN.md#ToSlice)]
|
||||
[[play](https://go.dev/play/p/jI6_iZZuVFE)]
|
||||
|
||||
### 19. structs 提供操作 struct, tag, field 的相关函数。
|
||||
### <span id="Structs">20. structs 提供操作 struct, tag, field 的相关函数。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/structs"
|
||||
@@ -1314,7 +1358,7 @@ import "github.com/duke-git/lancet/v2/structs"
|
||||
- **<big>IsSlice</big>** : 判断属性是否是切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/structs/field_zh-CN.md#IsSlice)]
|
||||
|
||||
### 20. strutil 包含字符串处理的相关函数。
|
||||
### <span id="Strutil">21. strutil 包含字符串处理的相关函数。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/strutil"
|
||||
@@ -1433,7 +1477,7 @@ import "github.com/duke-git/lancet/v2/strutil"
|
||||
- **<big>RemoveWhiteSpace</big>** : 删除字符串中的空格。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#RemoveWhiteSpace)]
|
||||
|
||||
### 21. system 包含 os, runtime, shell command 的相关函数。
|
||||
### <span id="System">22. system 包含 os, runtime, shell command 的相关函数。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/system"
|
||||
@@ -1469,7 +1513,88 @@ import "github.com/duke-git/lancet/v2/system"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/system_zh-CN#GetOsBits)]
|
||||
[[play](https://go.dev/play/p/ml-_XH3gJbW)]
|
||||
|
||||
### 22. validator 验证器包,包含常用字符串格式验证函数。
|
||||
### <span id="Tuple">23. Tuple 包实现一个元组数据类型。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/tuple"
|
||||
```
|
||||
|
||||
#### 函数列表:
|
||||
|
||||
- **<big>Tuple2</big>** : 2 元元组
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple2)]
|
||||
- **<big>Tuple2_Unbox</big>** : 返回 2 元元组的字段值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple2_Unbox)]
|
||||
- **<big>Zip2</big>** : 创建一个 Tuple2 元组切片, 其中元组的元素和传入切片元素相对应。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Zip2)]
|
||||
- **<big>Unzip2</big>** : 根据传入的Tuple2切片,创建一组和Tuple2元素相对应的切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Unzip2)]
|
||||
- **<big>Tuple3</big>** : 3 元元组
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple3)]
|
||||
- **<big>Tuple3_Unbox</big>** : 返回 3 元元组的字段值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple3_Unbox)]
|
||||
- **<big>Zip3</big>** : 创建一个 Tuple3 元组切片, 其中元组的元素和传入切片元素相对应。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Zip3)]
|
||||
- **<big>Unzip3</big>** : 根据传入的Tuple3切片,创建一组和Tuple3元素相对应的切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Unzip3)]
|
||||
- **<big>Tuple4</big>** : 4 元元组
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple4)]
|
||||
- **<big>Tuple4_Unbox</big>** : 返回 4 元元组的字段值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple4_Unbox)]
|
||||
- **<big>Zip4</big>** : 创建一个 Tuple4 元组切片, 其中元组的元素和传入切片元素相对应。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Zip4)]
|
||||
- **<big>Unzip4</big>** : 根据传入的Tuple4切片,创建一组和Tuple4元素相对应的切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Unzip4)]
|
||||
- **<big>Tuple5</big>** : 5 元元组
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple5)]
|
||||
- **<big>Tuple5_Unbox</big>** : 返回 5 元元组的字段值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple5_Unbox)]
|
||||
- **<big>Zip5</big>** : 创建一个 Tuple5 元组切片, 其中元组的元素和传入切片元素相对应。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Zip5)]
|
||||
- **<big>Unzip5</big>** : 根据传入的Tuple5切片,创建一组和Tuple5元素相对应的切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Unzip5)]
|
||||
- **<big>Tuple6</big>** : 6 元元组
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple6)]
|
||||
- **<big>Tuple6_Unbox</big>** : 返回 6 元元组的字段值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple6_Unbox)]
|
||||
- **<big>Zip6</big>** : 创建一个 Tuple6 元组切片, 其中元组的元素和传入切片元素相对应。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Zip6)]
|
||||
- **<big>Unzip6</big>** : 根据传入的Tuple6切片,创建一组和Tuple6元素相对应的切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Unzip6)]
|
||||
- **<big>Tuple7</big>** : 7 元元组
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple7)]
|
||||
- **<big>Tuple7_Unbox</big>** : 返回 7 元元组的字段值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple7_Unbox)]
|
||||
- **<big>Zip7</big>** : 创建一个 Tuple7 元组切片, 其中元组的元素和传入切片元素相对应。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Zip7)]
|
||||
- **<big>Unzip7</big>** : 根据传入的Tuple7切片,创建一组和Tuple7元素相对应的切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Unzip7)]
|
||||
- **<big>Tuple8</big>** : 8 元元组
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple8)]
|
||||
- **<big>Tuple8_Unbox</big>** : 返回 8 元元组的字段值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple8_Unbox)]
|
||||
- **<big>Zip8</big>** : 创建一个 Tuple8 元组切片, 其中元组的元素和传入切片元素相对应。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Zip8)]
|
||||
- **<big>Unzip8</big>** : 根据传入的Tuple8切片,创建一组和Tuple8元素相对应的切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Unzip8)]
|
||||
- **<big>Tuple9</big>** : 9 元元组
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple9)]
|
||||
- **<big>Tuple9_Unbox</big>** : 返回 9 元元组的字段值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple9_Unbox)]
|
||||
- **<big>Zip9</big>** : 创建一个 Tuple9 元组切片, 其中元组的元素和传入切片元素相对应。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Zip9)]
|
||||
- **<big>Unzip9</big>** : 根据传入的Tuple9切片,创建一组和Tuple9元素相对应的切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Unzip9)]
|
||||
- **<big>Tuple10</big>** : 10 元元组
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple10)]
|
||||
- **<big>Tuple10_Unbox</big>** : 返回 10 元元组的字段值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Tuple10_Unbox)]
|
||||
- **<big>Zip10</big>** : 创建一个 Tuple10 元组切片, 其中元组的元素和传入切片元素相对应。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Zip10)]
|
||||
- **<big>Unzip10</big>** : 根据传入的Tuple10切片,创建一组和Tuple10元素相对应的切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/tuple_zh-CN.md#Unzip10)]
|
||||
|
||||
### <span id="Validator">24. validator 验证器包,包含常用字符串格式验证函数。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/validator"
|
||||
@@ -1577,7 +1702,7 @@ import "github.com/duke-git/lancet/v2/validator"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsPrintable)]
|
||||
[[play](https://go.dev/play/p/Pe1FE2gdtTP)]
|
||||
|
||||
### 23. xerror 包实现一些错误处理函数
|
||||
### <span id="Xerror">25. xerror 包实现一些错误处理函数。</span> [回到目录](#index)
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/xerror"
|
||||
|
||||
Reference in New Issue
Block a user