mirror of
https://github.com/duke-git/lancet.git
synced 2025-12-19 17:02:23 +08:00
doc: update readme file
This commit is contained in:
28
README.md
28
README.md
@@ -84,6 +84,8 @@ func main() {
|
||||
- [Cryptor](#user-content-cryptor)
|
||||
- [Datetime](#user-content-datetime)
|
||||
- [Datastructure](#user-content-datastructure)
|
||||
- [EventBus](#user-content-eventbus)
|
||||
- [Enum](#user-content-enum)
|
||||
- [Fileutil](#user-content-fileutil)
|
||||
- [Formatter](#user-content-formatter)
|
||||
- [Function](#user-content-function)
|
||||
@@ -766,7 +768,7 @@ import "github.com/duke-git/lancet/v2/eventbus"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/eventbus.md#SetErrorHandler)]
|
||||
[[play](https://go.dev/play/p/gmB0gnFe5mc)]
|
||||
|
||||
<h3 id="eventbus"> 10. Package enum provides a simple enum implementation. <a href="#index">Index</a></h3>
|
||||
<h3 id="enum"> 10. Package enum provides a simple enum implementation. <a href="#index">Index</a></h3>
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/enum"
|
||||
@@ -789,43 +791,43 @@ import "github.com/duke-git/lancet/v2/enum"
|
||||
- **<big>Valid</big>** : Checks if the enum item is valid. If a custom check function is provided, it will be used to validate the value.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Valid)]
|
||||
[[play](https://go.dev/play/p/pA3lYY2VSm3)]
|
||||
- **<big>MarshalJSON</big>** : Implementation of json.Marshaler interface.</p>
|
||||
- **<big>MarshalJSON</big>** : Implementation of json.Marshaler interface.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#MarshalJSON)]
|
||||
[[play](https://go.dev/play/p/zIZEdAnneB5)]
|
||||
- **<big>NewRegistry</big>** : Creates a new enum registry..</p>
|
||||
- **<big>NewRegistry</big>** : Creates a new enum registry.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#NewRegistry)]
|
||||
[[play](https://go.dev/play/p/ABEXsYfJKMo)]
|
||||
- **<big>Add</big>** : Adds enum items to the registry.</p>
|
||||
- **<big>Add</big>** : Adds enum items to the registry.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Add)]
|
||||
[[play](https://go.dev/play/p/ABEXsYfJKMo)]
|
||||
- **<big>Remove</big>** : Removes an enum item from the registry by its value.</p>
|
||||
- **<big>Remove</big>** : Removes an enum item from the registry by its value.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Remove)]
|
||||
[[play](https://go.dev/play/p/dSG84wQ3TuC)]
|
||||
- **<big>Update</big>** : Updates the name of an enum item in the registry by its value.</p>
|
||||
- **<big>Update</big>** : Updates the name of an enum item in the registry by its value.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Update)]
|
||||
[[play](https://go.dev/play/p/Ol0moT1J9Xl)]
|
||||
- **<big>GetByValue</big>** : Retrieves an enum item by its value.</p>
|
||||
- **<big>GetByValue</big>** : Retrieves an enum item by its value.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#GetByValue)]
|
||||
[[play](https://go.dev/play/p/niJ1U2KlE_m)]
|
||||
- **<big>GetByName</big>** : Retrieves an enum item by its name.</p>
|
||||
- **<big>GetByName</big>** : Retrieves an enum item by its name.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#GetByName)]
|
||||
[[play](https://go.dev/play/p/49ie_gpqH0m)]
|
||||
- **<big>Items</big>** : Returns a slice of all enum items in the registry.</p>
|
||||
- **<big>Items</big>** : Returns a slice of all enum items in the registry.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Items)]
|
||||
[[play](https://go.dev/play/p/lAJFAradbvQ)]
|
||||
- **<big>Contains</big>** : Checks if an enum item with the given value exists in the registry.</p>
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Contains)]
|
||||
[[play](https://go.dev/play/p/_T-lPYkZn2j)]
|
||||
- **<big>Size</big>** : Returns the number of enum items in the registry.</p>
|
||||
- **<big>Size</big>** : Returns the number of enum items in the registry.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Size)]
|
||||
[[play](https://go.dev/play/p/TeDArWhlQe2)]
|
||||
- **<big>Range</big>** : Iterates over all enum items in the registry and applies the given function.</p>
|
||||
- **<big>Range</big>** : Iterates over all enum items in the registry and applies the given function.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Range)]
|
||||
[[play](https://go.dev/play/p/GPsZbQbefWN)]
|
||||
- **<big>SortedItems</big>** : Returns a slice of all enum items sorted by the given less function.</p>
|
||||
- **<big>SortedItems</big>** : Returns a slice of all enum items sorted by the given less function.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#SortedItems)]
|
||||
[[play](https://go.dev/play/p/tN9RE_m_WEI)]
|
||||
- **<big>Filter</big>** : Returns a slice of enum items that satisfy the given predicate function.</p>
|
||||
- **<big>Filter</big>** : Returns a slice of enum items that satisfy the given predicate function.
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/enum.md#Filter)]
|
||||
[[play](https://go.dev/play/p/uTUpTdcyoCU)]
|
||||
|
||||
|
||||
@@ -83,6 +83,8 @@ func main() {
|
||||
- [Cryptor](#user-content-cryptor)
|
||||
- [Datetime](#user-content-datetime)
|
||||
- [Datastructure](#user-content-datastructure)
|
||||
- [EventBus](#user-content-eventbus)
|
||||
- [Enum](#user-content-enum)
|
||||
- [Fileutil](#user-content-fileutil)
|
||||
- [Formatter](#user-content-formatter)
|
||||
- [Function](#user-content-function)
|
||||
@@ -776,7 +778,7 @@ import "github.com/duke-git/lancet/v2/eventbus"
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/eventbus.md#SetErrorHandler)]
|
||||
[[play](https://go.dev/play/p/gmB0gnFe5mc)]
|
||||
|
||||
<h3 id="eventbus"> 10. Enum实现一个简单枚举工具包。. <a href="#index">Index</a></h3>
|
||||
<h3 id="enum"> 10. Enum实现一个简单枚举工具包。. <a href="#index">Index</a></h3>
|
||||
|
||||
```go
|
||||
import "github.com/duke-git/lancet/v2/enum"
|
||||
@@ -799,43 +801,43 @@ import "github.com/duke-git/lancet/v2/enum"
|
||||
- **<big>Valid</big>** : 检查枚举项是否有效。如果提供了自定义检查函数,将使用该函数验证值。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Valid)]
|
||||
[[play](https://go.dev/play/p/pA3lYY2VSm3)]
|
||||
- **<big>MarshalJSON</big>** : 枚举项实现 json.Marshaler 接口。</p>
|
||||
- **<big>MarshalJSON</big>** : 枚举项实现 json.Marshaler 接口。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#MarshalJSON)]
|
||||
[[play](https://go.dev/play/p/zIZEdAnneB5)]
|
||||
- **<big>NewRegistry</big>** : Registry 定义了一个通用的枚举注册表结构体。</p>
|
||||
- **<big>NewRegistry</big>** : Registry 定义了一个通用的枚举注册表结构体。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#NewRegistry)]
|
||||
[[play](https://go.dev/play/p/ABEXsYfJKMo)]
|
||||
- **<big>Add</big>** : 向枚举注册表添加枚举项。</p>
|
||||
- **<big>Add</big>** : 向枚举注册表添加枚举项。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Add)]
|
||||
[[play](https://go.dev/play/p/ABEXsYfJKMo)]
|
||||
- **<big>Remove</big>** : 在枚举注册表中删除枚举项。</p>
|
||||
- **<big>Remove</big>** : 在枚举注册表中删除枚举项。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Remove)]
|
||||
[[play](https://go.dev/play/p/dSG84wQ3TuC)]
|
||||
- **<big>Update</big>** : 在枚举注册表中更新枚举项。</p>
|
||||
- **<big>Update</big>** : 在枚举注册表中更新枚举项。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Update)]
|
||||
[[play](https://go.dev/play/p/Ol0moT1J9Xl)]
|
||||
- **<big>GetByValue</big>** : 在枚举注册表中通过值获取枚举项。</p>
|
||||
- **<big>GetByValue</big>** : 在枚举注册表中通过值获取枚举项。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#GetByValue)]
|
||||
[[play](https://go.dev/play/p/niJ1U2KlE_m)]
|
||||
- **<big>GetByName</big>** : 在枚举注册表中通过名称获取枚举项。</p>
|
||||
- **<big>GetByName</big>** : 在枚举注册表中通过名称获取枚举项。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#GetByName)]
|
||||
[[play](https://go.dev/play/p/49ie_gpqH0m)]
|
||||
- **<big>Items</big>** : 返回枚举注册表中的枚举项。</p>
|
||||
- **<big>Items</big>** : 返回枚举注册表中的枚举项。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Items)]
|
||||
[[play](https://go.dev/play/p/lAJFAradbvQ)]
|
||||
- **<big>Contains</big>** : 检查注册表中是否存在具有给定值的枚举项。</p>
|
||||
- **<big>Contains</big>** : 检查注册表中是否存在具有给定值的枚举项。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Contains)]
|
||||
[[play](https://go.dev/play/p/_T-lPYkZn2j)]
|
||||
- **<big>Size</big>** : 返回注册表中枚举项的数目。</p>
|
||||
- **<big>Size</big>** : 返回注册表中枚举项的数目。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Size)]
|
||||
[[play](https://go.dev/play/p/TeDArWhlQe2)]
|
||||
- **<big>Range</big>** : 遍历注册表中的所有枚举项,并应用给定的函数。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Range)]
|
||||
[[play](https://go.dev/play/p/GPsZbQbefWN)]
|
||||
- **<big>SortedItems</big>** : 返回按给定比较函数排序的所有枚举项的切片。</p>
|
||||
- **<big>SortedItems</big>** : 返回按给定比较函数排序的所有枚举项的切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#SortedItems)]
|
||||
[[play](https://go.dev/play/p/tN9RE_m_WEI)]
|
||||
- **<big>Filter</big>** : 返回满足给定谓词函数的枚举项切片。</p>
|
||||
- **<big>Filter</big>** : 返回满足给定谓词函数的枚举项切片。
|
||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/enum.md#Filter)]
|
||||
[[play](https://go.dev/play/p/uTUpTdcyoCU)]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user