From bd7a3fee6b658c509f9e255cdba058b0eac8f209 Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Mon, 15 Jan 2024 10:37:51 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E4=BC=98=E5=8C=96=20README.md=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E7=AD=BE=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/activity/README.md | 12 +- game/fight/README.md | 2 +- game/space/README.md | 4 +- game/task/README.md | 16 +-- notify/README.md | 2 +- notify/notifies/README.md | 28 ++--- notify/senders/README.md | 2 +- planner/pce/README.md | 12 +- planner/pce/cs/README.md | 2 +- planner/pce/tmpls/README.md | 8 +- server/README.md | 64 +++++------ server/client/README.md | 10 +- server/gateway/README.md | 22 ++-- server/internal/dispatcher/README.md | 4 +- server/lockstep/README.md | 10 +- server/router/README.md | 4 +- server/writeloop/README.md | 4 +- utils/aoi/README.md | 2 +- utils/arrangement/README.md | 20 ++-- utils/buffer/README.md | 8 +- utils/collection/README.md | 130 +++++++++++----------- utils/collection/listings/README.md | 10 +- utils/collection/mappings/README.md | 2 +- utils/combination/README.md | 60 +++++----- utils/compress/README.md | 12 +- utils/crypto/README.md | 20 ++-- utils/deck/README.md | 4 +- utils/file/README.md | 20 ++-- utils/fsm/README.md | 12 +- utils/generator/astgo/README.md | 2 +- utils/generator/genreadme/README.md | 6 +- utils/generator/genreadme/builder.go | 16 ++- utils/generator/genreadme/builder_test.go | 4 +- utils/generic/README.md | 6 +- utils/geometry/README.md | 122 ++++++++++---------- utils/geometry/astar/README.md | 2 +- utils/geometry/dp/README.md | 2 +- utils/geometry/matrix/README.md | 2 +- utils/geometry/navmesh/README.md | 2 +- utils/hub/README.md | 2 +- utils/huge/README.md | 8 +- utils/leaderboard/README.md | 6 +- utils/log/README.md | 88 +++++++-------- utils/log/survey/README.md | 10 +- utils/maths/README.md | 40 +++---- utils/memory/README.md | 6 +- utils/moving/README.md | 10 +- utils/offset/README.md | 8 +- utils/random/README.md | 46 ++++---- utils/reflects/README.md | 6 +- utils/runtimes/README.md | 10 +- utils/sole/README.md | 22 ++-- utils/sorts/README.md | 2 +- utils/str/README.md | 42 +++---- utils/super/README.md | 130 +++++++++++----------- utils/timer/README.md | 8 +- utils/times/README.md | 88 +++++++-------- utils/xlsxtool/README.md | 2 +- 58 files changed, 608 insertions(+), 596 deletions(-) diff --git a/game/activity/README.md b/game/activity/README.md index ec9848b..77dd01e 100644 --- a/game/activity/README.md +++ b/game/activity/README.md @@ -75,28 +75,28 @@ activity 活动状态管理 > 加载所有活动实体数据 *** -#### func LoadOrRefreshActivity(activityType Type, activityId ID, options ...*Options) error +#### func LoadOrRefreshActivity(activityType Type, activityId ID, options ...*Options) error > 加载或刷新活动 > - 通常在活动配置刷新时候将活动通过该方法注册或刷新 *** -#### func DefineNoneDataActivity(activityType Type) NoneDataActivityController[Type, ID, *none, none, *none] +#### func DefineNoneDataActivity(activityType Type) NoneDataActivityController[Type, ID, *none, none, *none] > 声明无数据的活动类型 *** -#### func DefineGlobalDataActivity(activityType Type) GlobalDataActivityController[Type, ID, Data, none, *none] +#### func DefineGlobalDataActivity(activityType Type) GlobalDataActivityController[Type, ID, Data, none, *none] > 声明拥有全局数据的活动类型 *** -#### func DefineEntityDataActivity(activityType Type) EntityDataActivityController[Type, ID, *none, EntityID, EntityData] +#### func DefineEntityDataActivity(activityType Type) EntityDataActivityController[Type, ID, *none, EntityID, EntityData] > 声明拥有实体数据的活动类型 *** -#### func DefineGlobalAndEntityDataActivity(activityType Type) GlobalAndEntityDataActivityController[Type, ID, Data, EntityID, EntityData] +#### func DefineGlobalAndEntityDataActivity(activityType Type) GlobalAndEntityDataActivityController[Type, ID, Data, EntityID, EntityData] > 声明拥有全局数据和实体数据的活动类型 @@ -161,7 +161,7 @@ activity 活动状态管理 > 新的一天事件 *** -#### func NewOptions() *Options +#### func NewOptions() *Options > 创建活动选项 diff --git a/game/fight/README.md b/game/fight/README.md index 2b977fc..144feeb 100644 --- a/game/fight/README.md +++ b/game/fight/README.md @@ -34,7 +34,7 @@ *** ## 详情信息 -#### func NewTurnBased(calcNextTurnDuration func ( Camp, Entity) time.Duration) *TurnBased[CampID, EntityID, Camp, Entity] +#### func NewTurnBased(calcNextTurnDuration func ( Camp, Entity) time.Duration) *TurnBased[CampID, EntityID, Camp, Entity] > 创建一个新的回合制 > - calcNextTurnDuration 将返回下一次行动时间间隔,适用于按照速度计算下一次行动时间间隔的情况。当返回 0 时,将使用默认的行动超时时间 diff --git a/game/space/README.md b/game/space/README.md index 58e3d32..55dc53c 100644 --- a/game/space/README.md +++ b/game/space/README.md @@ -34,7 +34,7 @@ space 游戏中常见的空间设计,例如房间、地图等 *** ## 详情信息 -#### func NewRoomManager() *RoomManager[EntityID, RoomID, Entity, Room] +#### func NewRoomManager() *RoomManager[EntityID, RoomID, Entity, Room] > 创建房间管理器 RoomManager 的实例 @@ -49,7 +49,7 @@ func ExampleNewRoomManager() { ``` *** -#### func NewRoomControllerOptions() *RoomControllerOptions[EntityID, RoomID, Entity, Room] +#### func NewRoomControllerOptions() *RoomControllerOptions[EntityID, RoomID, Entity, Room] > 创建房间控制器选项 diff --git a/game/task/README.md b/game/task/README.md index 3d5d02f..9c116b9 100644 --- a/game/task/README.md +++ b/game/task/README.md @@ -45,7 +45,7 @@ *** ## 详情信息 -#### func Cond(k any, v any) Condition +#### func Cond(k any, v any) Condition > 创建任务条件 @@ -108,19 +108,19 @@ func TestCond(t *testing.T) { > 触发特定任务类型的刷新任务条件事件 *** -#### func WithType(taskType string) Option +#### func WithType(taskType string) Option > 设置任务类型 *** -#### func WithCondition(condition Condition) Option +#### func WithCondition(condition Condition) Option > 设置任务完成条件,当满足条件时,任务状态为完成 > - 任务条件值需要变更时可通过 Task.AssignConditionValueAndRefresh 方法变更 > - 当多次设置该选项时,后面的设置会覆盖之前的设置 *** -#### func WithCounter(counter int64, initCount ...int64) Option +#### func WithCounter(counter int64, initCount ...int64) Option > 设置任务计数器,当计数器达到要求时,任务状态为完成 > - 一些场景下,任务计数器可能会溢出,此时可通过 WithOverflowCounter 设置可溢出的任务计数器 @@ -128,24 +128,24 @@ func TestCond(t *testing.T) { > - 如果需要初始化计数器的值,可通过 initCount 参数设置 *** -#### func WithOverflowCounter(counter int64, initCount ...int64) Option +#### func WithOverflowCounter(counter int64, initCount ...int64) Option > 设置可溢出的任务计数器,当计数器达到要求时,任务状态为完成 > - 当多次设置该选项时,后面的设置会覆盖之前的设置 > - 如果需要初始化计数器的值,可通过 initCount 参数设置 *** -#### func WithDeadline(deadline time.Time) Option +#### func WithDeadline(deadline time.Time) Option > 设置任务截止时间,超过截至时间并且任务未完成时,任务状态为失败 *** -#### func WithLimitedDuration(start time.Time, duration time.Duration) Option +#### func WithLimitedDuration(start time.Time, duration time.Duration) Option > 设置任务限时,超过限时时间并且任务未完成时,任务状态为失败 *** -#### func NewTask(options ...Option) *Task +#### func NewTask(options ...Option) *Task > 生成任务 diff --git a/notify/README.md b/notify/README.md index 284040b..4d1c98e 100644 --- a/notify/README.md +++ b/notify/README.md @@ -32,7 +32,7 @@ notify 包含了对外部第三方通知的实现,如机器人消息等 *** ## 详情信息 -#### func NewManager(senders ...Sender) *Manager +#### func NewManager(senders ...Sender) *Manager > 通过指定的 Sender 创建一个通知管理器, senders 包中提供了一些内置的 Sender diff --git a/notify/notifies/README.md b/notify/notifies/README.md index 7b99d6e..21dfa21 100644 --- a/notify/notifies/README.md +++ b/notify/notifies/README.md @@ -45,12 +45,12 @@ notifies 包含了内置通知内容的实现 *** ## 详情信息 -#### func NewFeiShu(message FeiShuMessage) *FeiShu +#### func NewFeiShu(message FeiShuMessage) *FeiShu > 创建飞书通知消息 *** -#### func FeiShuMessageWithText(text string) FeiShuMessage +#### func FeiShuMessageWithText(text string) FeiShuMessage > 飞书文本消息 > - 支持通过换行符进行消息换行 @@ -68,24 +68,24 @@ notifies 包含了内置通知内容的实现 > - 请确保链接是合法的,否则会以原始内容发送消息。 *** -#### func FeiShuMessageWithRichText(richText *FeiShuRichText) FeiShuMessage +#### func FeiShuMessageWithRichText(richText *FeiShuRichText) FeiShuMessage > 飞书富文本消息 *** -#### func FeiShuMessageWithImage(imageKey string) FeiShuMessage +#### func FeiShuMessageWithImage(imageKey string) FeiShuMessage > 飞书图片消息 > - imageKey 可通过上传图片接口获取 *** -#### func FeiShuMessageWithInteractive(json string) FeiShuMessage +#### func FeiShuMessageWithInteractive(json string) FeiShuMessage > 飞书卡片消息 > - json 表示卡片的 json 数据或者消息模板的 json 数据 *** -#### func FeiShuMessageWithShareChat(chatId string) FeiShuMessage +#### func FeiShuMessageWithShareChat(chatId string) FeiShuMessage > 飞书分享群名片 > - chatId 群ID获取方式请参见群ID说明 @@ -93,7 +93,7 @@ notifies 包含了内置通知内容的实现 > 群ID说明:https://open.feishu.cn/document/server-docs/group/chat/chat-id-description *** -#### func FeiShuMessageWithShareUser(userId string) FeiShuMessage +#### func FeiShuMessageWithShareUser(userId string) FeiShuMessage > 飞书分享个人名片 > - userId 表示用户的 OpenID 获取方式请参见了解更多:如何获取 Open ID @@ -101,7 +101,7 @@ notifies 包含了内置通知内容的实现 > 如何获取 Open ID:https://open.feishu.cn/document/faq/trouble-shooting/how-to-obtain-openid *** -#### func FeiShuMessageWithAudio(fileKey string) FeiShuMessage +#### func FeiShuMessageWithAudio(fileKey string) FeiShuMessage > 飞书语音消息 > - fileKey 语音文件Key,可通过上传文件接口获取 @@ -109,7 +109,7 @@ notifies 包含了内置通知内容的实现 > 上传文件:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/file/create *** -#### func FeiShuMessageWithMedia(fileKey string) FeiShuMessage +#### func FeiShuMessageWithMedia(fileKey string) FeiShuMessage > 飞书视频消息 > - fileKey 视频文件Key,可通过上传文件接口获取 @@ -117,7 +117,7 @@ notifies 包含了内置通知内容的实现 > 上传文件:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/file/create *** -#### func FeiShuMessageWithMediaAndCover(fileKey string, imageKey string) FeiShuMessage +#### func FeiShuMessageWithMediaAndCover(fileKey string, imageKey string) FeiShuMessage > 飞书带封面的视频消息 > - fileKey 视频文件Key,可通过上传文件接口获取 @@ -126,7 +126,7 @@ notifies 包含了内置通知内容的实现 > 上传文件:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/file/create *** -#### func FeiShuMessageWithFile(fileKey string) FeiShuMessage +#### func FeiShuMessageWithFile(fileKey string) FeiShuMessage > 飞书文件消息 > - fileKey 文件Key,可通过上传文件接口获取 @@ -134,7 +134,7 @@ notifies 包含了内置通知内容的实现 > 上传文件:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/file/create *** -#### func FeiShuMessageWithSticker(fileKey string) FeiShuMessage +#### func FeiShuMessageWithSticker(fileKey string) FeiShuMessage > 飞书表情包消息 > - fileKey 表情包文件Key,目前仅支持发送机器人收到的表情包,可通过接收消息事件的推送获取表情包 file_key。 @@ -142,7 +142,7 @@ notifies 包含了内置通知内容的实现 > 接收消息事件:https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/message/events/receive *** -#### func NewFeiShuRichText() *FeiShuRichText +#### func NewFeiShuRichText() *FeiShuRichText > 创建一个飞书富文本 @@ -155,7 +155,7 @@ type FeiShu struct { MsgType string } ``` -#### func (*FeiShu) Format() string, error +#### func (*FeiShu) Format() ( string, error) > 格式化通知内容 *** ### FeiShuMessage `STRUCT` diff --git a/notify/senders/README.md b/notify/senders/README.md index a446930..5038d8b 100644 --- a/notify/senders/README.md +++ b/notify/senders/README.md @@ -30,7 +30,7 @@ senders Package 包含了内置通知发送器的实现 *** ## 详情信息 -#### func NewFeiShu(webhook string) *FeiShu +#### func NewFeiShu(webhook string) *FeiShu > 根据特定的 webhook 地址创建飞书发送器 diff --git a/planner/pce/README.md b/planner/pce/README.md index dd10bdd..2d07abb 100644 --- a/planner/pce/README.md +++ b/planner/pce/README.md @@ -69,12 +69,12 @@ *** ## 详情信息 -#### func NewExporter() *Exporter +#### func NewExporter() *Exporter > 创建导出器 *** -#### func GetFieldGolangType(field Field) string +#### func GetFieldGolangType(field Field) string > 获取字段的 Golang 类型 @@ -95,12 +95,12 @@ func TestGetFieldGolangType(t *testing.T) { *** -#### func GetFields() []Field +#### func GetFields() []Field > 获取所有内置支持的字段 *** -#### func NewLoader(fields []Field) *Loader +#### func NewLoader(fields []Field) *Loader > 创建加载器 > - 加载器被用于加载配置表的数据和结构信息 @@ -132,10 +132,10 @@ type DataTmpl interface { ```go type Exporter struct{} ``` -#### func (*Exporter) ExportStruct(tmpl Tmpl, tmplStruct ...*TmplStruct) []byte, error +#### func (*Exporter) ExportStruct(tmpl Tmpl, tmplStruct ...*TmplStruct) ( []byte, error) > 导出结构 *** -#### func (*Exporter) ExportData(tmpl DataTmpl, data map[any]any) []byte, error +#### func (*Exporter) ExportData(tmpl DataTmpl, data map[any]any) ( []byte, error) > 导出数据 *** ### Field `INTERFACE` diff --git a/planner/pce/cs/README.md b/planner/pce/cs/README.md index 87e0cde..85c2332 100644 --- a/planner/pce/cs/README.md +++ b/planner/pce/cs/README.md @@ -31,7 +31,7 @@ *** ## 详情信息 -#### func NewXlsx(sheet *xlsx.Sheet, exportType XlsxExportType) *Xlsx +#### func NewXlsx(sheet *xlsx.Sheet, exportType XlsxExportType) *Xlsx *** diff --git a/planner/pce/tmpls/README.md b/planner/pce/tmpls/README.md index e0b1bb7..dab5451 100644 --- a/planner/pce/tmpls/README.md +++ b/planner/pce/tmpls/README.md @@ -32,12 +32,12 @@ *** ## 详情信息 -#### func NewGolang(packageName string) *Golang +#### func NewGolang(packageName string) *Golang > 创建一个 Golang 配置导出模板 *** -#### func NewJSON() *JSON +#### func NewJSON() *JSON *** @@ -49,7 +49,7 @@ type Golang struct { Templates []*pce.TmplStruct } ``` -#### func (*Golang) Render(templates ...*pce.TmplStruct) string, error +#### func (*Golang) Render(templates ...*pce.TmplStruct) ( string, error) *** #### func (*Golang) GetVariable(config *pce.TmplStruct) string *** @@ -64,5 +64,5 @@ type JSON struct { jsonIter.API } ``` -#### func (*JSON) Render(data map[any]any) string, error +#### func (*JSON) Render(data map[any]any) ( string, error) *** diff --git a/server/README.md b/server/README.md index a79cad6..02ca621 100644 --- a/server/README.md +++ b/server/README.md @@ -80,7 +80,7 @@ server 提供了包含多种网络类型的服务器实现 *** ## 详情信息 -#### func NewBot(srv *Server, options ...BotOption) *Bot +#### func NewBot(srv *Server, options ...BotOption) *Bot > 创建一个机器人,目前仅支持 Socket 服务器 @@ -122,151 +122,151 @@ func TestNewBot(t *testing.T) { *** -#### func WithBotNetworkDelay(delay time.Duration, fluctuation time.Duration) BotOption +#### func WithBotNetworkDelay(delay time.Duration, fluctuation time.Duration) BotOption > 设置机器人网络延迟及波动范围 > - delay 延迟 > - fluctuation 波动范围 *** -#### func WithBotWriter(construction func (bot *Bot) io.Writer) BotOption +#### func WithBotWriter(construction func (bot *Bot) io.Writer) BotOption > 设置机器人写入器,默认为 os.Stdout *** -#### func DefaultWebsocketUpgrader() *websocket.Upgrader +#### func DefaultWebsocketUpgrader() *websocket.Upgrader *** -#### func NewHttpHandleWrapper(srv *Server, packer ContextPacker[Context]) *Http[Context] +#### func NewHttpHandleWrapper(srv *Server, packer ContextPacker[Context]) *Http[Context] > 创建一个新的 http 处理程序包装器 > - 默认使用 server.HttpContext 作为上下文,如果需要依赖其作为新的上下文,可以通过 NewHttpContext 创建 *** -#### func NewHttpContext(ctx *gin.Context) *HttpContext +#### func NewHttpContext(ctx *gin.Context) *HttpContext > 基于 gin.Context 创建一个新的 HttpContext *** -#### func NewGinWrapper(server *gin.Engine, pack func (ctx *gin.Context) CTX) *HttpWrapper[CTX] +#### func NewGinWrapper(server *gin.Engine, pack func (ctx *gin.Context) CTX) *HttpWrapper[CTX] > 创建 gin 包装器,用于对 NewHttpWrapper 函数的替代 *** -#### func HasMessageType(mt MessageType) bool +#### func HasMessageType(mt MessageType) bool > 检查是否存在指定的消息类型 *** -#### func NewMultipleServer(serverHandle ...func () ((addr string, srv *Server))) *MultipleServer +#### func NewMultipleServer(serverHandle ...func () ((addr string, srv *Server))) *MultipleServer *** -#### func GetNetworks() []Network +#### func GetNetworks() []Network > 获取所有支持的网络模式 *** -#### func WithLowMessageDuration(duration time.Duration) Option +#### func WithLowMessageDuration(duration time.Duration) Option > 通过指定慢消息时长的方式创建服务器,当消息处理时间超过指定时长时,将会输出 WARN 类型的日志 > - 默认值为 DefaultLowMessageDuration > - 当 duration <= 0 时,表示关闭慢消息检测 *** -#### func WithAsyncLowMessageDuration(duration time.Duration) Option +#### func WithAsyncLowMessageDuration(duration time.Duration) Option > 通过指定异步消息的慢消息时长的方式创建服务器,当消息处理时间超过指定时长时,将会输出 WARN 类型的日志 > - 默认值为 DefaultAsyncLowMessageDuration > - 当 duration <= 0 时,表示关闭慢消息检测 *** -#### func WithWebsocketConnInitializer(initializer func (writer http.ResponseWriter, request *http.Request, conn *websocket.Conn) error) Option +#### func WithWebsocketConnInitializer(initializer func (writer http.ResponseWriter, request *http.Request, conn *websocket.Conn) error) Option > 通过 websocket 连接初始化的方式创建服务器,当 initializer 返回错误时,服务器将不会处理该连接的后续逻辑 > - 该选项仅在创建 NetworkWebsocket 服务器时有效 *** -#### func WithWebsocketUpgrade(upgrader *websocket.Upgrader) Option +#### func WithWebsocketUpgrade(upgrader *websocket.Upgrader) Option > 通过指定 websocket.Upgrader 的方式创建服务器 > - 默认值为 DefaultWebsocketUpgrader > - 该选项仅在创建 NetworkWebsocket 服务器时有效 *** -#### func WithConnWriteBufferSize(size int) Option +#### func WithConnWriteBufferSize(size int) Option > 通过连接写入缓冲区大小的方式创建服务器 > - 默认值为 DefaultConnWriteBufferSize > - 设置合适的缓冲区大小可以提高服务器性能,但是会占用更多的内存 *** -#### func WithDispatcherBufferSize(size int) Option +#### func WithDispatcherBufferSize(size int) Option > 通过消息分发器缓冲区大小的方式创建服务器 > - 默认值为 DefaultDispatcherBufferSize > - 设置合适的缓冲区大小可以提高服务器性能,但是会占用更多的内存 *** -#### func WithMessageStatistics(duration time.Duration, limit int) Option +#### func WithMessageStatistics(duration time.Duration, limit int) Option > 通过消息统计的方式创建服务器 > - 默认不开启,当 duration 和 limit 均大于 0 的时候,服务器将记录每 duration 期间的消息数量,并保留最多 limit 条 *** -#### func WithPacketWarnSize(size int) Option +#### func WithPacketWarnSize(size int) Option > 通过数据包大小警告的方式创建服务器,当数据包大小超过指定大小时,将会输出 WARN 类型的日志 > - 默认值为 DefaultPacketWarnSize > - 当 size <= 0 时,表示不设置警告 *** -#### func WithLimitLife(t time.Duration) Option +#### func WithLimitLife(t time.Duration) Option > 通过限制最大生命周期的方式创建服务器 > - 通常用于测试服务器,服务器将在到达最大生命周期时自动关闭 *** -#### func WithWebsocketWriteCompression() Option +#### func WithWebsocketWriteCompression() Option > 通过数据写入压缩的方式创建Websocket服务器 > - 默认不开启数据压缩 *** -#### func WithWebsocketCompression(level int) Option +#### func WithWebsocketCompression(level int) Option > 通过数据压缩的方式创建Websocket服务器 > - 默认不开启数据压缩 *** -#### func WithDeadlockDetect(t time.Duration) Option +#### func WithDeadlockDetect(t time.Duration) Option > 通过死锁、死循环、永久阻塞检测的方式创建服务器 > - 当检测到死锁、死循环、永久阻塞时,服务器将会生成 WARN 类型的日志,关键字为 "SuspectedDeadlock" > - 默认不开启死锁检测 *** -#### func WithDisableAsyncMessage() Option +#### func WithDisableAsyncMessage() Option > 通过禁用异步消息的方式创建服务器 *** -#### func WithAsyncPoolSize(size int) Option +#### func WithAsyncPoolSize(size int) Option > 通过指定异步消息池大小的方式创建服务器 > - 当通过 WithDisableAsyncMessage 禁用异步消息时,此选项无效 > - 默认值为 DefaultAsyncPoolSize *** -#### func WithWebsocketReadDeadline(t time.Duration) Option +#### func WithWebsocketReadDeadline(t time.Duration) Option > 设置 Websocket 读取超时时间 > - 默认: DefaultWebsocketReadDeadline > - 当 t <= 0 时,表示不设置超时时间 *** -#### func WithTicker(poolSize int, size int, connSize int, autonomy bool) Option +#### func WithTicker(poolSize int, size int, connSize int, autonomy bool) Option > 通过定时器创建服务器,为服务器添加定时器功能 > - poolSize:指定服务器定时器池大小,当池子内的定时器数量超出该值后,多余的定时器在释放时将被回收,该值小于等于 0 时将使用 timer.DefaultTickerPoolSize @@ -275,28 +275,28 @@ func TestNewBot(t *testing.T) { > - autonomy:定时器是否独立运行(独立运行的情况下不会作为服务器消息运行,会导致并发问题) *** -#### func WithTLS(certFile string, keyFile string) Option +#### func WithTLS(certFile string, keyFile string) Option > 通过安全传输层协议TLS创建服务器 > - 支持:Http、Websocket *** -#### func WithGRPCServerOptions(options ...grpc.ServerOption) Option +#### func WithGRPCServerOptions(options ...grpc.ServerOption) Option > 通过GRPC的可选项创建GRPC服务器 *** -#### func WithWebsocketMessageType(messageTypes ...int) Option +#### func WithWebsocketMessageType(messageTypes ...int) Option > 设置仅支持特定类型的Websocket消息 *** -#### func WithPProf(pattern ...string) Option +#### func WithPProf(pattern ...string) Option > 通过性能分析工具PProf创建服务器 *** -#### func New(network Network, options ...Option) *Server +#### func New(network Network, options ...Option) *Server > 根据特定网络类型创建一个服务器 @@ -866,7 +866,7 @@ func ExampleServer_Run() { #### func (*Server) Context() context.Context > 获取服务器上下文 *** -#### func (*Server) TimeoutContext(timeout time.Duration) context.Context, context.CancelFunc +#### func (*Server) TimeoutContext(timeout time.Duration) ( context.Context, context.CancelFunc) > 获取服务器超时上下文,context.WithTimeout 的简写 *** #### func (*Server) Ticker() *timer.Ticker diff --git a/server/client/README.md b/server/client/README.md index ad20045..ee5bc4c 100644 --- a/server/client/README.md +++ b/server/client/README.md @@ -40,25 +40,25 @@ *** ## 详情信息 -#### func NewClient(core Core) *Client +#### func NewClient(core Core) *Client > 创建客户端 *** -#### func CloneClient(client *Client) *Client +#### func CloneClient(client *Client) *Client > 克隆客户端 *** -#### func NewTCP(addr string) *Client +#### func NewTCP(addr string) *Client *** -#### func NewUnixDomainSocket(addr string) *Client +#### func NewUnixDomainSocket(addr string) *Client *** -#### func NewWebsocket(addr string) *Client +#### func NewWebsocket(addr string) *Client > 创建 websocket 客户端 diff --git a/server/gateway/README.md b/server/gateway/README.md index 831a22f..224b2ba 100644 --- a/server/gateway/README.md +++ b/server/gateway/README.md @@ -45,17 +45,17 @@ gateway 是用于处理服务器消息的网关模块,适用于对客户端消 *** ## 详情信息 -#### func NewEndpoint(name string, cli *client.Client, options ...EndpointOption) *Endpoint +#### func NewEndpoint(name string, cli *client.Client, options ...EndpointOption) *Endpoint > 创建网关端点 *** -#### func WithEndpointStateEvaluator(evaluator func (costUnixNano float64) float64) EndpointOption +#### func WithEndpointStateEvaluator(evaluator func (costUnixNano float64) float64) EndpointOption > 设置端点健康值评估函数 *** -#### func WithEndpointConnectionPoolSize(size int) EndpointOption +#### func WithEndpointConnectionPoolSize(size int) EndpointOption > 设置端点连接池大小 > - 默认为 DefaultEndpointConnectionPoolSize @@ -63,25 +63,25 @@ gateway 是用于处理服务器消息的网关模块,适用于对客户端消 > - 在网关服务器中,多个客户端在发送消息到端点服务器时,会共用一个连接,适当的增大连接池大小可以提高网关服务器的承载能力 *** -#### func WithEndpointReconnectInterval(interval time.Duration) EndpointOption +#### func WithEndpointReconnectInterval(interval time.Duration) EndpointOption > 设置端点重连间隔 > - 默认为 DefaultEndpointReconnectInterval > - 端点在连接失败后会在该间隔后重连,如果 <= 0 则不会重连 *** -#### func NewGateway(srv *server.Server, scanner Scanner, options ...Option) *Gateway +#### func NewGateway(srv *server.Server, scanner Scanner, options ...Option) *Gateway > 基于 server.Server 创建 Gateway 网关服务器 *** -#### func WithEndpointSelector(selector EndpointSelector) Option +#### func WithEndpointSelector(selector EndpointSelector) Option > 设置端点选择器 > - 默认情况下,网关会随机选择一个端点作为目标,如果需要自定义端点选择器,可以通过该选项设置 *** -#### func MarshalGatewayOutPacket(addr string, packet []byte) []byte, error +#### func MarshalGatewayOutPacket(addr string, packet []byte) ([]byte, error) > 将数据包转换为网关出网数据包 > - | identifier(4) | ipv4(4) | port(2) | packet | @@ -93,7 +93,7 @@ gateway 是用于处理服务器消息的网关模块,适用于对客户端消 > - | identifier(4) | ipv4(4) | port(2) | packet | *** -#### func MarshalGatewayInPacket(addr string, currentTime int64, packet []byte) []byte, error +#### func MarshalGatewayInPacket(addr string, currentTime int64, packet []byte) ([]byte, error) > 将数据包转换为网关入网数据包 > - | ipv4(4) | port(2) | cost(4) | packet | @@ -218,11 +218,11 @@ func TestGateway_Run(t *testing.T) { #### func (*Gateway) Server() *server.Server > 获取网关服务器核心 *** -#### func (*Gateway) GetEndpoint(name string) *Endpoint, error +#### func (*Gateway) GetEndpoint(name string) ( *Endpoint, error) > 获取一个可用的端点 > - name: 端点名称 *** -#### func (*Gateway) GetConnEndpoint(name string, conn *server.Conn) *Endpoint, error +#### func (*Gateway) GetConnEndpoint(name string, conn *server.Conn) ( *Endpoint, error) > 获取一个可用的端点,如果客户端已经连接到了某个端点,将优先返回该端点 > - 当连接到的端点不可用或没有连接记录时,效果同 GetEndpoint 相同 > - 当连接行为为有状态时,推荐使用该方法 @@ -243,7 +243,7 @@ type Scanner interface { GetInterval() time.Duration } ``` -#### func (*Scanner) GetEndpoints() []*gateway.Endpoint, error +#### func (*Scanner) GetEndpoints() ( []*gateway.Endpoint, error) *** #### func (*Scanner) GetInterval() time.Duration *** diff --git a/server/internal/dispatcher/README.md b/server/internal/dispatcher/README.md index ac41cf8..1d3bd6e 100644 --- a/server/internal/dispatcher/README.md +++ b/server/internal/dispatcher/README.md @@ -36,7 +36,7 @@ *** ## 详情信息 -#### func NewDispatcher(bufferSize int, name string, handler Handler[P, M]) *Dispatcher[P, M] +#### func NewDispatcher(bufferSize int, name string, handler Handler[P, M]) *Dispatcher[P, M] > 创建一个新的消息分发器 Dispatcher 实例 @@ -107,7 +107,7 @@ func TestNewDispatcher(t *testing.T) { *** -#### func NewManager(bufferSize int, handler Handler[P, M]) *Manager[P, M] +#### func NewManager(bufferSize int, handler Handler[P, M]) *Manager[P, M] > 生成消息分发器管理器 diff --git a/server/lockstep/README.md b/server/lockstep/README.md index 5be645f..f7a5a72 100644 --- a/server/lockstep/README.md +++ b/server/lockstep/README.md @@ -37,7 +37,7 @@ *** ## 详情信息 -#### func NewLockstep(options ...Option[ClientID, Command]) *Lockstep[ClientID, Command] +#### func NewLockstep(options ...Option[ClientID, Command]) *Lockstep[ClientID, Command] > 创建一个锁步(帧)同步默认实现的组件(Lockstep)进行返回 @@ -78,19 +78,19 @@ func TestNewLockstep(t *testing.T) { *** -#### func WithFrameLimit(frameLimit int64) Option[ClientID, Command] +#### func WithFrameLimit(frameLimit int64) Option[ClientID, Command] > 通过特定逻辑帧上限创建锁步(帧)同步组件 > - 当达到上限时将停止广播 *** -#### func WithFrameRate(frameRate int64) Option[ClientID, Command] +#### func WithFrameRate(frameRate int64) Option[ClientID, Command] > 通过特定逻辑帧率创建锁步(帧)同步组件 > - 默认情况下为 15/s *** -#### func WithSerialization(handle func (frame int64, commands []Command) []byte) Option[ClientID, Command] +#### func WithSerialization(handle func (frame int64, commands []Command) []byte) Option[ClientID, Command] > 通过特定的序列化方式将每一帧的数据进行序列化 > @@ -102,7 +102,7 @@ func TestNewLockstep(t *testing.T) { > } *** -#### func WithInitFrame(initFrame int64) Option[ClientID, Command] +#### func WithInitFrame(initFrame int64) Option[ClientID, Command] > 通过特定的初始帧创建锁步(帧)同步组件 > - 默认情况下为 0,即第一帧索引为 0 diff --git a/server/router/README.md b/server/router/README.md index 2c28968..7a470bc 100644 --- a/server/router/README.md +++ b/server/router/README.md @@ -33,7 +33,7 @@ *** ## 详情信息 -#### func NewMultistage(options ...MultistageOption[HandleFunc]) *Multistage[HandleFunc] +#### func NewMultistage(options ...MultistageOption[HandleFunc]) *Multistage[HandleFunc] > 创建一个支持多级分类的路由器 @@ -47,7 +47,7 @@ func ExampleNewMultistage() { ``` *** -#### func WithRouteTrim(handle func (route any) any) MultistageOption[HandleFunc] +#### func WithRouteTrim(handle func (route any) any) MultistageOption[HandleFunc] > 路由修剪选项 > - 将在路由注册前对路由进行对应处理 diff --git a/server/writeloop/README.md b/server/writeloop/README.md index 73dfc13..173ca78 100644 --- a/server/writeloop/README.md +++ b/server/writeloop/README.md @@ -33,7 +33,7 @@ *** ## 详情信息 -#### func NewChannel(pool *hub.ObjectPool[Message], channelSize int, writeHandler func (message Message) error, errorHandler func (err any)) *Channel[Message] +#### func NewChannel(pool *hub.ObjectPool[Message], channelSize int, writeHandler func (message Message) error, errorHandler func (err any)) *Channel[Message] > 创建基于 Channel 的写循环 > - pool 用于管理 Message 对象的缓冲池,在创建 Message 对象时也应该使用该缓冲池,以便复用 Message 对象。 Channel 会在写入完成后将 Message 对象放回缓冲池 @@ -44,7 +44,7 @@ > 传入 writeHandler 的消息对象是从 Channel 中获取的,因此 writeHandler 不应该持有消息对象的引用,同时也不应该主动释放消息对象 *** -#### func NewUnbounded(pool *hub.ObjectPool[Message], writeHandler func (message Message) error, errorHandler func (err any)) *Unbounded[Message] +#### func NewUnbounded(pool *hub.ObjectPool[Message], writeHandler func (message Message) error, errorHandler func (err any)) *Unbounded[Message] > 创建写循环 > - pool 用于管理 Message 对象的缓冲池,在创建 Message 对象时也应该使用该缓冲池,以便复用 Message 对象。 Unbounded 会在写入完成后将 Message 对象放回缓冲池 diff --git a/utils/aoi/README.md b/utils/aoi/README.md index e2c7429..c03f1f6 100644 --- a/utils/aoi/README.md +++ b/utils/aoi/README.md @@ -37,7 +37,7 @@ AOI 问题是在大规模多人在线游戏中常见的问题,它涉及到确 *** ## 详情信息 -#### func NewTwoDimensional(width int, height int, areaWidth int, areaHeight int) *TwoDimensional[EID, PosType, E] +#### func NewTwoDimensional(width int, height int, areaWidth int, areaHeight int) *TwoDimensional[EID, PosType, E]
diff --git a/utils/arrangement/README.md b/utils/arrangement/README.md index 93dcdb3..8caab46 100644 --- a/utils/arrangement/README.md +++ b/utils/arrangement/README.md @@ -50,54 +50,54 @@ arrangement 包提供了一些有用的函数来处理数组的排列。 *** ## 详情信息 -#### func WithAreaConstraint(constraint AreaConstraintHandle[ID, AreaInfo]) AreaOption[ID, AreaInfo] +#### func WithAreaConstraint(constraint AreaConstraintHandle[ID, AreaInfo]) AreaOption[ID, AreaInfo] > 设置编排区域的约束条件 > - 该约束用于判断一个成员是否可以被添加到该编排区域中 > - 与 WithAreaConflict 不同的是,约束通常用于非成员关系导致的硬性约束,例如:成员的等级过滤、成员的性别等 *** -#### func WithAreaConflict(conflict AreaConflictHandle[ID, AreaInfo]) AreaOption[ID, AreaInfo] +#### func WithAreaConflict(conflict AreaConflictHandle[ID, AreaInfo]) AreaOption[ID, AreaInfo] > 设置编排区域的冲突条件,冲突处理函数需要返回造成冲突的成员列表 > - 该冲突用于判断一个成员是否可以被添加到该编排区域中 > - 与 WithAreaConstraint 不同的是,冲突通常用于成员关系导致的软性约束,例如:成员的职业唯一性、成员的种族唯一性等 *** -#### func WithAreaEvaluate(evaluate AreaEvaluateHandle[ID, AreaInfo]) AreaOption[ID, AreaInfo] +#### func WithAreaEvaluate(evaluate AreaEvaluateHandle[ID, AreaInfo]) AreaOption[ID, AreaInfo] > 设置编排区域的评估函数 > - 该评估函数将影响成员被编入区域的优先级 *** -#### func NewArrangement(options ...Option[ID, AreaInfo]) *Arrangement[ID, AreaInfo] +#### func NewArrangement(options ...Option[ID, AreaInfo]) *Arrangement[ID, AreaInfo] > 创建一个新的编排 *** -#### func WithItemFixed(matcher ItemFixedAreaHandle[AreaInfo]) ItemOption[ID, AreaInfo] +#### func WithItemFixed(matcher ItemFixedAreaHandle[AreaInfo]) ItemOption[ID, AreaInfo] > 设置成员的固定编排区域 *** -#### func WithItemPriority(priority ItemPriorityHandle[ID, AreaInfo]) ItemOption[ID, AreaInfo] +#### func WithItemPriority(priority ItemPriorityHandle[ID, AreaInfo]) ItemOption[ID, AreaInfo] > 设置成员的优先级 *** -#### func WithItemNotAllow(verify ItemNotAllowVerifyHandle[ID, AreaInfo]) ItemOption[ID, AreaInfo] +#### func WithItemNotAllow(verify ItemNotAllowVerifyHandle[ID, AreaInfo]) ItemOption[ID, AreaInfo] > 设置成员不允许的编排区域 *** -#### func WithRetryThreshold(threshold int) Option[ID, AreaInfo] +#### func WithRetryThreshold(threshold int) Option[ID, AreaInfo] > 设置编排时的重试阈值 > - 当每一轮编排结束任有成员未被编排时,将会进行下一轮编排,直到编排次数达到该阈值 > - 默认的阈值为 10 次 *** -#### func WithConstraintHandle(handle ConstraintHandle[ID, AreaInfo]) Option[ID, AreaInfo] +#### func WithConstraintHandle(handle ConstraintHandle[ID, AreaInfo]) Option[ID, AreaInfo] > 设置编排时触发约束时的处理函数 > - 当约束条件触发时,将会调用该函数。如果无法在该函数中处理约束,应该继续返回 err,尝试进行下一层的约束处理 @@ -107,7 +107,7 @@ arrangement 包提供了一些有用的函数来处理数组的排列。 > 有意思的是,硬性约束应该永远是无解的,而当需要进行一些打破规则的操作时,则可以透过该函数传入的 editor 进行操作 *** -#### func WithConflictHandle(handle ConflictHandle[ID, AreaInfo]) Option[ID, AreaInfo] +#### func WithConflictHandle(handle ConflictHandle[ID, AreaInfo]) Option[ID, AreaInfo] > 设置编排时触发冲突时的处理函数 > - 当冲突条件触发时,将会调用该函数。如果无法在该函数中处理冲突,应该继续返回这一批成员,尝试进行下一层的冲突处理 diff --git a/utils/buffer/README.md b/utils/buffer/README.md index b56d19e..b0f0d88 100644 --- a/utils/buffer/README.md +++ b/utils/buffer/README.md @@ -40,7 +40,7 @@ buffer 提供了缓冲区相关的实用程序。 *** ## 详情信息 -#### func NewRing(initSize ...int) *Ring[T] +#### func NewRing(initSize ...int) *Ring[T] > 创建一个并发不安全的环形缓冲区 > - initSize: 初始容量 @@ -68,12 +68,12 @@ func TestNewRing(t *testing.T) { *** -#### func NewRingUnbounded(bufferSize int) *RingUnbounded[T] +#### func NewRingUnbounded(bufferSize int) *RingUnbounded[T] > 创建一个并发安全的基于环形缓冲区实现的无界缓冲区 *** -#### func NewUnbounded() *Unbounded[V] +#### func NewUnbounded() *Unbounded[V] > 创建一个无界缓冲区 > - generateNil: 生成空值的函数,该函数仅需始终返回 nil 即可 @@ -93,7 +93,7 @@ type Ring[T any] struct { w int } ``` -#### func (*Ring) Read() T, error +#### func (*Ring) Read() ( T, error) > 读取数据
查看 / 收起基准测试 diff --git a/utils/collection/README.md b/utils/collection/README.md index 1fa259f..b9663e9 100644 --- a/utils/collection/README.md +++ b/utils/collection/README.md @@ -141,7 +141,7 @@ collection 用于对 input 和 map 操作的工具函数 *** ## 详情信息 -#### func CloneSlice(slice S) S +#### func CloneSlice(slice S) S > 克隆切片,该函数是 slices.Clone 的快捷方式 @@ -190,7 +190,7 @@ func TestCloneSlice(t *testing.T) { *** -#### func CloneMap(m M) M +#### func CloneMap(m M) M > 克隆 map @@ -239,7 +239,7 @@ func TestCloneMap(t *testing.T) { *** -#### func CloneSliceN(slice S, n int) []S +#### func CloneSliceN(slice S, n int) []S > 克隆 slice 为 n 个切片进行返回 @@ -294,7 +294,7 @@ func TestCloneSliceN(t *testing.T) { *** -#### func CloneMapN(m M, n int) []M +#### func CloneMapN(m M, n int) []M > 克隆 map 为 n 个 map 进行返回 @@ -349,7 +349,7 @@ func TestCloneMapN(t *testing.T) { *** -#### func CloneSlices(slices ...S) []S +#### func CloneSlices(slices ...S) []S > 克隆多个切片 @@ -401,7 +401,7 @@ func TestCloneSlices(t *testing.T) { *** -#### func CloneMaps(maps ...M) []M +#### func CloneMaps(maps ...M) []M > 克隆多个 map @@ -453,7 +453,7 @@ func TestCloneMaps(t *testing.T) { *** -#### func InSlice(slice S, v V, handler ComparisonHandler[V]) bool +#### func InSlice(slice S, v V, handler ComparisonHandler[V]) bool > 检查 v 是否被包含在 slice 中,当 handler 返回 true 时,表示 v 和 slice 中的某个元素相匹配 @@ -501,7 +501,7 @@ func TestInSlice(t *testing.T) { *** -#### func InComparableSlice(slice S, v V) bool +#### func InComparableSlice(slice S, v V) bool > 检查 v 是否被包含在 slice 中 @@ -545,7 +545,7 @@ func TestInComparableSlice(t *testing.T) { *** -#### func AllInSlice(slice S, values []V, handler ComparisonHandler[V]) bool +#### func AllInSlice(slice S, values []V, handler ComparisonHandler[V]) bool > 检查 values 中的所有元素是否均被包含在 slice 中,当 handler 返回 true 时,表示 values 中的某个元素和 slice 中的某个元素相匹配 > - 在所有 values 中的元素都被包含在 slice 中时,返回 true @@ -595,7 +595,7 @@ func TestAllInSlice(t *testing.T) { *** -#### func AllInComparableSlice(slice S, values []V) bool +#### func AllInComparableSlice(slice S, values []V) bool > 检查 values 中的所有元素是否均被包含在 slice 中 > - 在所有 values 中的元素都被包含在 slice 中时,返回 true @@ -641,7 +641,7 @@ func TestAllInComparableSlice(t *testing.T) { *** -#### func AnyInSlice(slice S, values []V, handler ComparisonHandler[V]) bool +#### func AnyInSlice(slice S, values []V, handler ComparisonHandler[V]) bool > 检查 values 中的任意一个元素是否被包含在 slice 中,当 handler 返回 true 时,表示 value 中的某个元素和 slice 中的某个元素相匹配 > - 当 values 中的任意一个元素被包含在 slice 中时,返回 true @@ -690,7 +690,7 @@ func TestAnyInSlice(t *testing.T) { *** -#### func AnyInComparableSlice(slice S, values []V) bool +#### func AnyInComparableSlice(slice S, values []V) bool > 检查 values 中的任意一个元素是否被包含在 slice 中 > - 当 values 中的任意一个元素被包含在 slice 中时,返回 true @@ -735,7 +735,7 @@ func TestAnyInComparableSlice(t *testing.T) { *** -#### func InSlices(slices []S, v V, handler ComparisonHandler[V]) bool +#### func InSlices(slices []S, v V, handler ComparisonHandler[V]) bool > 通过将多个切片合并后检查 v 是否被包含在 slices 中,当 handler 返回 true 时,表示 v 和 slices 中的某个元素相匹配 > - 当传入的 v 被包含在 slices 的任一成员中时,返回 true @@ -784,7 +784,7 @@ func TestInSlices(t *testing.T) { *** -#### func InComparableSlices(slices []S, v V) bool +#### func InComparableSlices(slices []S, v V) bool > 通过将多个切片合并后检查 v 是否被包含在 slices 中 > - 当传入的 v 被包含在 slices 的任一成员中时,返回 true @@ -829,7 +829,7 @@ func TestInComparableSlices(t *testing.T) { *** -#### func AllInSlices(slices []S, values []V, handler ComparisonHandler[V]) bool +#### func AllInSlices(slices []S, values []V, handler ComparisonHandler[V]) bool > 通过将多个切片合并后检查 values 中的所有元素是否被包含在 slices 中,当 handler 返回 true 时,表示 values 中的某个元素和 slices 中的某个元素相匹配 > - 当 values 中的所有元素都被包含在 slices 的任一成员中时,返回 true @@ -878,7 +878,7 @@ func TestAllInSlices(t *testing.T) { *** -#### func AllInComparableSlices(slices []S, values []V) bool +#### func AllInComparableSlices(slices []S, values []V) bool > 通过将多个切片合并后检查 values 中的所有元素是否被包含在 slices 中 > - 当 values 中的所有元素都被包含在 slices 的任一成员中时,返回 true @@ -923,7 +923,7 @@ func TestAllInComparableSlices(t *testing.T) { *** -#### func AnyInSlices(slices []S, values []V, handler ComparisonHandler[V]) bool +#### func AnyInSlices(slices []S, values []V, handler ComparisonHandler[V]) bool > 通过将多个切片合并后检查 values 中的任意一个元素是否被包含在 slices 中,当 handler 返回 true 时,表示 values 中的某个元素和 slices 中的某个元素相匹配 > - 当 values 中的任意一个元素被包含在 slices 的任一成员中时,返回 true @@ -972,7 +972,7 @@ func TestAnyInSlices(t *testing.T) { *** -#### func AnyInComparableSlices(slices []S, values []V) bool +#### func AnyInComparableSlices(slices []S, values []V) bool > 通过将多个切片合并后检查 values 中的任意一个元素是否被包含在 slices 中 > - 当 values 中的任意一个元素被包含在 slices 的任一成员中时,返回 true @@ -1017,7 +1017,7 @@ func TestAnyInComparableSlices(t *testing.T) { *** -#### func InAllSlices(slices []S, v V, handler ComparisonHandler[V]) bool +#### func InAllSlices(slices []S, v V, handler ComparisonHandler[V]) bool > 检查 v 是否被包含在 slices 的每一项元素中,当 handler 返回 true 时,表示 v 和 slices 中的某个元素相匹配 > - 当 v 被包含在 slices 的每一项元素中时,返回 true @@ -1066,7 +1066,7 @@ func TestInAllSlices(t *testing.T) { *** -#### func InAllComparableSlices(slices []S, v V) bool +#### func InAllComparableSlices(slices []S, v V) bool > 检查 v 是否被包含在 slices 的每一项元素中 > - 当 v 被包含在 slices 的每一项元素中时,返回 true @@ -1111,7 +1111,7 @@ func TestInAllComparableSlices(t *testing.T) { *** -#### func AnyInAllSlices(slices []S, values []V, handler ComparisonHandler[V]) bool +#### func AnyInAllSlices(slices []S, values []V, handler ComparisonHandler[V]) bool > 检查 slices 中的每一个元素是否均包含至少任意一个 values 中的元素,当 handler 返回 true 时,表示 value 中的某个元素和 slices 中的某个元素相匹配 > - 当 slices 中的每一个元素均包含至少任意一个 values 中的元素时,返回 true @@ -1160,7 +1160,7 @@ func TestAnyInAllSlices(t *testing.T) { *** -#### func AnyInAllComparableSlices(slices []S, values []V) bool +#### func AnyInAllComparableSlices(slices []S, values []V) bool > 检查 slices 中的每一个元素是否均包含至少任意一个 values 中的元素 > - 当 slices 中的每一个元素均包含至少任意一个 values 中的元素时,返回 true @@ -1205,7 +1205,7 @@ func TestAnyInAllComparableSlices(t *testing.T) { *** -#### func KeyInMap(m M, key K) bool +#### func KeyInMap(m M, key K) bool > 检查 m 中是否包含特定 key @@ -1249,7 +1249,7 @@ func TestKeyInMap(t *testing.T) { *** -#### func ValueInMap(m M, value V, handler ComparisonHandler[V]) bool +#### func ValueInMap(m M, value V, handler ComparisonHandler[V]) bool > 检查 m 中是否包含特定 value,当 handler 返回 true 时,表示 value 和 m 中的某个元素相匹配 @@ -1296,7 +1296,7 @@ func TestValueInMap(t *testing.T) { *** -#### func AllKeyInMap(m M, keys ...K) bool +#### func AllKeyInMap(m M, keys ...K) bool > 检查 m 中是否包含 keys 中所有的元素 @@ -1340,7 +1340,7 @@ func TestAllKeyInMap(t *testing.T) { *** -#### func AllValueInMap(m M, values []V, handler ComparisonHandler[V]) bool +#### func AllValueInMap(m M, values []V, handler ComparisonHandler[V]) bool > 检查 m 中是否包含 values 中所有的元素,当 handler 返回 true 时,表示 values 中的某个元素和 m 中的某个元素相匹配 @@ -1386,7 +1386,7 @@ func TestAllValueInMap(t *testing.T) { *** -#### func AnyKeyInMap(m M, keys ...K) bool +#### func AnyKeyInMap(m M, keys ...K) bool > 检查 m 中是否包含 keys 中任意一个元素 @@ -1430,7 +1430,7 @@ func TestAnyKeyInMap(t *testing.T) { *** -#### func AnyValueInMap(m M, values []V, handler ComparisonHandler[V]) bool +#### func AnyValueInMap(m M, values []V, handler ComparisonHandler[V]) bool > 检查 m 中是否包含 values 中任意一个元素,当 handler 返回 true 时,表示 values 中的某个元素和 m 中的某个元素相匹配 @@ -1476,7 +1476,7 @@ func TestAnyValueInMap(t *testing.T) { *** -#### func AllKeyInMaps(maps []M, keys ...K) bool +#### func AllKeyInMaps(maps []M, keys ...K) bool > 检查 maps 中的每一个元素是否均包含 keys 中所有的元素 @@ -1520,7 +1520,7 @@ func TestAllKeyInMaps(t *testing.T) { *** -#### func AllValueInMaps(maps []M, values []V, handler ComparisonHandler[V]) bool +#### func AllValueInMaps(maps []M, values []V, handler ComparisonHandler[V]) bool > 检查 maps 中的每一个元素是否均包含 value 中所有的元素,当 handler 返回 true 时,表示 value 中的某个元素和 maps 中的某个元素相匹配 @@ -1566,7 +1566,7 @@ func TestAllValueInMaps(t *testing.T) { *** -#### func AnyKeyInMaps(maps []M, keys ...K) bool +#### func AnyKeyInMaps(maps []M, keys ...K) bool > 检查 keys 中的任意一个元素是否被包含在 maps 中的任意一个元素中 > - 当 keys 中的任意一个元素被包含在 maps 中的任意一个元素中时,返回 true @@ -1611,7 +1611,7 @@ func TestAnyKeyInMaps(t *testing.T) { *** -#### func AnyValueInMaps(maps []M, values []V, handler ComparisonHandler[V]) bool +#### func AnyValueInMaps(maps []M, values []V, handler ComparisonHandler[V]) bool > 检查 maps 中的任意一个元素是否包含 value 中的任意一个元素,当 handler 返回 true 时,表示 value 中的某个元素和 maps 中的某个元素相匹配 > - 当 maps 中的任意一个元素包含 value 中的任意一个元素时,返回 true @@ -1658,7 +1658,7 @@ func TestAnyValueInMaps(t *testing.T) { *** -#### func KeyInAllMaps(maps []M, key K) bool +#### func KeyInAllMaps(maps []M, key K) bool > 检查 key 是否被包含在 maps 的每一个元素中 @@ -1702,7 +1702,7 @@ func TestKeyInAllMaps(t *testing.T) { *** -#### func AnyKeyInAllMaps(maps []M, keys []K) bool +#### func AnyKeyInAllMaps(maps []M, keys []K) bool > 检查 maps 中的每一个元素是否均包含 keys 中任意一个元素 > - 当 maps 中的每一个元素均包含 keys 中任意一个元素时,返回 true @@ -1747,7 +1747,7 @@ func TestAnyKeyInAllMaps(t *testing.T) { *** -#### func ConvertSliceToAny(s S) []any +#### func ConvertSliceToAny(s S) []any > 将切片转换为任意类型的切片 @@ -1799,7 +1799,7 @@ func TestConvertSliceToAny(t *testing.T) { *** -#### func ConvertSliceToIndexMap(s S) map[int]V +#### func ConvertSliceToIndexMap(s S) map[int]V > 将切片转换为索引为键的映射 @@ -1850,7 +1850,7 @@ func TestConvertSliceToIndexMap(t *testing.T) { *** -#### func ConvertSliceToIndexOnlyMap(s S) map[int]struct {} +#### func ConvertSliceToIndexOnlyMap(s S) map[int]struct {} > 将切片转换为索引为键的映射 @@ -1905,7 +1905,7 @@ func TestConvertSliceToIndexOnlyMap(t *testing.T) { *** -#### func ConvertSliceToMap(s S) map[V]struct {} +#### func ConvertSliceToMap(s S) map[V]struct {} > 将切片转换为值为键的映射 @@ -1957,7 +1957,7 @@ func TestConvertSliceToMap(t *testing.T) { *** -#### func ConvertSliceToBoolMap(s S) map[V]bool +#### func ConvertSliceToBoolMap(s S) map[V]bool > 将切片转换为值为键的映射 @@ -2008,7 +2008,7 @@ func TestConvertSliceToBoolMap(t *testing.T) { *** -#### func ConvertMapKeysToSlice(m M) []K +#### func ConvertMapKeysToSlice(m M) []K > 将映射的键转换为切片 @@ -2064,7 +2064,7 @@ func TestConvertMapKeysToSlice(t *testing.T) { *** -#### func ConvertMapValuesToSlice(m M) []V +#### func ConvertMapValuesToSlice(m M) []V > 将映射的值转换为切片 @@ -2121,7 +2121,7 @@ func TestConvertMapValuesToSlice(t *testing.T) { *** -#### func InvertMap(m M) N +#### func InvertMap(m M) N > 将映射的键和值互换 @@ -2169,7 +2169,7 @@ func TestInvertMap(t *testing.T) { *** -#### func ConvertMapValuesToBool(m M) N +#### func ConvertMapValuesToBool(m M) N > 将映射的值转换为布尔值 @@ -2592,7 +2592,7 @@ func TestDeduplicateSliceInPlace(t *testing.T) { *** -#### func DeduplicateSlice(s S) S +#### func DeduplicateSlice(s S) S > 去除切片中的重复元素,返回新切片 @@ -2695,7 +2695,7 @@ func TestDeduplicateSliceInPlaceWithCompare(t *testing.T) { *** -#### func DeduplicateSliceWithCompare(s S, compare func (a V) bool) S +#### func DeduplicateSliceWithCompare(s S, compare func (a V) bool) S > 去除切片中的重复元素,使用自定义的比较函数,返回新的切片 @@ -2748,7 +2748,7 @@ func TestDeduplicateSliceWithCompare(t *testing.T) { *** -#### func FilterOutByIndices(slice S, indices ...int) S +#### func FilterOutByIndices(slice S, indices ...int) S > 过滤切片中特定索引的元素,返回过滤后的切片 @@ -2798,7 +2798,7 @@ func TestFilterOutByIndices(t *testing.T) { *** -#### func FilterOutByCondition(slice S, condition func (v V) bool) S +#### func FilterOutByCondition(slice S, condition func (v V) bool) S > 过滤切片中符合条件的元素,返回过滤后的切片 > - condition 的返回值为 true 时,将会过滤掉该元素 @@ -2857,7 +2857,7 @@ func TestFilterOutByCondition(t *testing.T) { *** -#### func FilterOutByKey(m M, key K) M +#### func FilterOutByKey(m M, key K) M > 过滤 map 中特定的 key,返回过滤后的 map @@ -2907,7 +2907,7 @@ func TestFilterOutByKey(t *testing.T) { *** -#### func FilterOutByValue(m M, value V, handler ComparisonHandler[V]) M +#### func FilterOutByValue(m M, value V, handler ComparisonHandler[V]) M > 过滤 map 中特定的 value,返回过滤后的 map @@ -2961,7 +2961,7 @@ func TestFilterOutByValue(t *testing.T) { *** -#### func FilterOutByKeys(m M, keys ...K) M +#### func FilterOutByKeys(m M, keys ...K) M > 过滤 map 中多个 key,返回过滤后的 map @@ -3011,7 +3011,7 @@ func TestFilterOutByKeys(t *testing.T) { *** -#### func FilterOutByValues(m M, values []V, handler ComparisonHandler[V]) M +#### func FilterOutByValues(m M, values []V, handler ComparisonHandler[V]) M > 过滤 map 中多个 values,返回过滤后的 map @@ -3067,7 +3067,7 @@ func TestFilterOutByValues(t *testing.T) { *** -#### func FilterOutByMap(m M, condition func (k K, v V) bool) M +#### func FilterOutByMap(m M, condition func (k K, v V) bool) M > 过滤 map 中符合条件的元素,返回过滤后的 map > - condition 的返回值为 true 时,将会过滤掉该元素 @@ -3212,7 +3212,7 @@ func TestFindLoopedPrevInSlice(t *testing.T) { *** -#### func FindCombinationsInSliceByRange(s S, minSize int, maxSize int) []S +#### func FindCombinationsInSliceByRange(s S, minSize int, maxSize int) []S > 获取给定数组的所有组合,且每个组合的成员数量限制在指定范围内 @@ -3257,7 +3257,7 @@ func TestFindCombinationsInSliceByRange(t *testing.T) { *** -#### func FindFirstOrDefaultInSlice(slice S, defaultValue V) V +#### func FindFirstOrDefaultInSlice(slice S, defaultValue V) V > 判断切片中是否存在元素,返回第一个元素,不存在则返回默认值 @@ -3437,7 +3437,7 @@ func TestFindInSlice(t *testing.T) { *** -#### func FindIndexInSlice(slice S, handler func (v V) bool) int +#### func FindIndexInSlice(slice S, handler func (v V) bool) int > 判断切片中是否存在某个元素,返回第一个匹配的索引,不存在则索引返回 -1 @@ -3527,7 +3527,7 @@ func TestFindInComparableSlice(t *testing.T) { *** -#### func FindIndexInComparableSlice(slice S, v V) int +#### func FindIndexInComparableSlice(slice S, v V) int > 判断切片中是否存在某个元素,返回第一个匹配的索引,不存在则索引返回 -1 @@ -4158,7 +4158,7 @@ func TestSwapSlice(t *testing.T) { *** -#### func MappingFromSlice(slice S, handler func (value V) N) NS +#### func MappingFromSlice(slice S, handler func (value V) N) NS > 将切片中的元素进行转换 @@ -4210,7 +4210,7 @@ func TestMappingFromSlice(t *testing.T) { *** -#### func MappingFromMap(m M, handler func (value V) N) NM +#### func MappingFromMap(m M, handler func (value V) N) NM > 将 map 中的元素进行转换 @@ -4744,7 +4744,7 @@ func TestChooseRandomMapValueRepeatN(t *testing.T) { *** -#### func ChooseRandomMapKeyAndValueRepeatN(m M, n int) M +#### func ChooseRandomMapKeyAndValueRepeatN(m M, n int) M > 获取 map 中的 n 个随机 key 和 v,允许重复 > - 如果 n 大于 map 长度或小于 0 时将会发生 panic @@ -4977,7 +4977,7 @@ func TestChooseRandomMapKeyAndValue(t *testing.T) { *** -#### func ChooseRandomMapKeyAndValueN(m M, n int) M +#### func ChooseRandomMapKeyAndValueN(m M, n int) M > 获取 map 中的 inputN 个随机 key 和 v > - 如果 n 大于 map 长度或小于 0 时将会发生 panic @@ -5023,7 +5023,7 @@ func TestChooseRandomMapKeyAndValueN(t *testing.T) { *** -#### func DescBy(a Sort, b Sort) bool +#### func DescBy(a Sort, b Sort) bool > 返回降序比较结果 @@ -5073,7 +5073,7 @@ func TestDescBy(t *testing.T) { *** -#### func AscBy(a Sort, b Sort) bool +#### func AscBy(a Sort, b Sort) bool > 返回升序比较结果 @@ -5173,7 +5173,7 @@ func TestDesc(t *testing.T) { *** -#### func DescByClone(slice S, getter func (index int) Sort) S +#### func DescByClone(slice S, getter func (index int) Sort) S > 对切片进行降序排序,返回排序后的切片 @@ -5273,7 +5273,7 @@ func TestAsc(t *testing.T) { *** -#### func AscByClone(slice S, getter func (index int) Sort) S +#### func AscByClone(slice S, getter func (index int) Sort) S > 对切片进行升序排序,返回排序后的切片 @@ -5367,7 +5367,7 @@ func TestShuffle(t *testing.T) { *** -#### func ShuffleByClone(slice S) S +#### func ShuffleByClone(slice S) S > 对切片进行随机排序,返回排序后的切片 diff --git a/utils/collection/listings/README.md b/utils/collection/listings/README.md index 57dd1d8..0ea0d9f 100644 --- a/utils/collection/listings/README.md +++ b/utils/collection/listings/README.md @@ -36,22 +36,22 @@ *** ## 详情信息 -#### func NewMatrix(dimensions ...int) *Matrix[V] +#### func NewMatrix(dimensions ...int) *Matrix[V] > 创建一个新的 Matrix 实例。 *** -#### func NewPagedSlice(pageSize int) *PagedSlice[T] +#### func NewPagedSlice(pageSize int) *PagedSlice[T] > 创建一个新的 PagedSlice 实例。 *** -#### func NewPrioritySlice(lengthAndCap ...int) *PrioritySlice[V] +#### func NewPrioritySlice(lengthAndCap ...int) *PrioritySlice[V] > 创建一个优先级切片 *** -#### func NewSyncSlice(length int, cap int) *SyncSlice[V] +#### func NewSyncSlice(length int, cap int) *SyncSlice[V] > 创建一个 SyncSlice @@ -145,7 +145,7 @@ func TestPrioritySlice_Append(t *testing.T) { #### func (*PrioritySlice) Appends(priority int, vs ...V) > 添加元素 *** -#### func (*PrioritySlice) Get(index int) V, int +#### func (*PrioritySlice) Get(index int) ( V, int) > 获取元素 *** #### func (*PrioritySlice) GetValue(index int) V diff --git a/utils/collection/mappings/README.md b/utils/collection/mappings/README.md index 0fa7236..f4910eb 100644 --- a/utils/collection/mappings/README.md +++ b/utils/collection/mappings/README.md @@ -30,7 +30,7 @@ *** ## 详情信息 -#### func NewSyncMap(source ...map[K]V) *SyncMap[K, V] +#### func NewSyncMap(source ...map[K]V) *SyncMap[K, V] > 创建一个 SyncMap diff --git a/utils/combination/README.md b/utils/combination/README.md index 0efb527..2826bbe 100644 --- a/utils/combination/README.md +++ b/utils/combination/README.md @@ -65,12 +65,12 @@ combination 包提供了一些实用的组合函数。 *** ## 详情信息 -#### func NewCombination(options ...Option[T]) *Combination[T] +#### func NewCombination(options ...Option[T]) *Combination[T] > 创建一个新的组合器 *** -#### func WithEvaluation(evaluate func (items []T) float64) Option[T] +#### func WithEvaluation(evaluate func (items []T) float64) Option[T] > 设置组合评估函数 > - 用于对组合进行评估,返回一个分值的评价函数 @@ -79,57 +79,57 @@ combination 包提供了一些实用的组合函数。 > - 默认的评估函数将返回一个随机数 *** -#### func NewMatcher(options ...MatcherOption[T]) *Matcher[T] +#### func NewMatcher(options ...MatcherOption[T]) *Matcher[T] > 创建一个新的匹配器 *** -#### func WithMatcherEvaluation(evaluate func (items []T) float64) MatcherOption[T] +#### func WithMatcherEvaluation(evaluate func (items []T) float64) MatcherOption[T] > 设置匹配器评估函数 > - 用于对组合进行评估,返回一个分值的评价函数 > - 通过该选项将覆盖匹配器的默认(WithEvaluation)评估函数 *** -#### func WithMatcherLeastLength(length int) MatcherOption[T] +#### func WithMatcherLeastLength(length int) MatcherOption[T] > 通过匹配最小长度的组合创建匹配器 > - length: 组合的长度,表示需要匹配的组合最小数量 *** -#### func WithMatcherLength(length int) MatcherOption[T] +#### func WithMatcherLength(length int) MatcherOption[T] > 通过匹配长度的组合创建匹配器 > - length: 组合的长度,表示需要匹配的组合数量 *** -#### func WithMatcherMostLength(length int) MatcherOption[T] +#### func WithMatcherMostLength(length int) MatcherOption[T] > 通过匹配最大长度的组合创建匹配器 > - length: 组合的长度,表示需要匹配的组合最大数量 *** -#### func WithMatcherIntervalLength(min int, max int) MatcherOption[T] +#### func WithMatcherIntervalLength(min int, max int) MatcherOption[T] > 通过匹配长度区间的组合创建匹配器 > - min: 组合的最小长度,表示需要匹配的组合最小数量 > - max: 组合的最大长度,表示需要匹配的组合最大数量 *** -#### func WithMatcherContinuity(getIndex func (item T) Index) MatcherOption[T] +#### func WithMatcherContinuity(getIndex func (item T) Index) MatcherOption[T] > 通过匹配连续的组合创建匹配器 > - index: 用于获取组合中元素的索引值,用于判断是否连续 *** -#### func WithMatcherSame(count int, getType func (item T) E) MatcherOption[T] +#### func WithMatcherSame(count int, getType func (item T) E) MatcherOption[T] > 通过匹配相同的组合创建匹配器 > - count: 组合中相同元素的数量,当 count <= 0 时,表示相同元素的数量不限 > - getType: 用于获取组合中元素的类型,用于判断是否相同 *** -#### func WithMatcherNCarryM(n int, m int, getType func (item T) E) MatcherOption[T] +#### func WithMatcherNCarryM(n int, m int, getType func (item T) E) MatcherOption[T] > 通过匹配 N 携带 M 的组合创建匹配器 > - n: 组合中元素的数量,表示需要匹配的组合数量,n 的类型需要全部相同 @@ -137,7 +137,7 @@ combination 包提供了一些实用的组合函数。 > - getType: 用于获取组合中元素的类型,用于判断是否相同 *** -#### func WithMatcherNCarryIndependentM(n int, m int, getType func (item T) E) MatcherOption[T] +#### func WithMatcherNCarryIndependentM(n int, m int, getType func (item T) E) MatcherOption[T] > 通过匹配 N 携带独立 M 的组合创建匹配器 > - n: 组合中元素的数量,表示需要匹配的组合数量,n 的类型需要全部相同 @@ -145,87 +145,87 @@ combination 包提供了一些实用的组合函数。 > - getType: 用于获取组合中元素的类型,用于判断是否相同 *** -#### func NewValidator(options ...ValidatorOption[T]) *Validator[T] +#### func NewValidator(options ...ValidatorOption[T]) *Validator[T] > 创建一个新的校验器 *** -#### func WithValidatorHandle(handle func (items []T) bool) ValidatorOption[T] +#### func WithValidatorHandle(handle func (items []T) bool) ValidatorOption[T] > 通过特定的验证函数对组合进行验证 *** -#### func WithValidatorHandleLength(length int) ValidatorOption[T] +#### func WithValidatorHandleLength(length int) ValidatorOption[T] > 校验组合的长度是否符合要求 *** -#### func WithValidatorHandleLengthRange(min int, max int) ValidatorOption[T] +#### func WithValidatorHandleLengthRange(min int, max int) ValidatorOption[T] > 校验组合的长度是否在指定的范围内 *** -#### func WithValidatorHandleLengthMin(min int) ValidatorOption[T] +#### func WithValidatorHandleLengthMin(min int) ValidatorOption[T] > 校验组合的长度是否大于等于指定的最小值 *** -#### func WithValidatorHandleLengthMax(max int) ValidatorOption[T] +#### func WithValidatorHandleLengthMax(max int) ValidatorOption[T] > 校验组合的长度是否小于等于指定的最大值 *** -#### func WithValidatorHandleLengthNot(length int) ValidatorOption[T] +#### func WithValidatorHandleLengthNot(length int) ValidatorOption[T] > 校验组合的长度是否不等于指定的值 *** -#### func WithValidatorHandleTypeLength(length int, getType func (item T) E) ValidatorOption[T] +#### func WithValidatorHandleTypeLength(length int, getType func (item T) E) ValidatorOption[T] > 校验组合成员类型数量是否为指定的值 *** -#### func WithValidatorHandleTypeLengthRange(min int, max int, getType func (item T) E) ValidatorOption[T] +#### func WithValidatorHandleTypeLengthRange(min int, max int, getType func (item T) E) ValidatorOption[T] > 校验组合成员类型数量是否在指定的范围内 *** -#### func WithValidatorHandleTypeLengthMin(min int, getType func (item T) E) ValidatorOption[T] +#### func WithValidatorHandleTypeLengthMin(min int, getType func (item T) E) ValidatorOption[T] > 校验组合成员类型数量是否大于等于指定的最小值 *** -#### func WithValidatorHandleTypeLengthMax(max int, getType func (item T) E) ValidatorOption[T] +#### func WithValidatorHandleTypeLengthMax(max int, getType func (item T) E) ValidatorOption[T] > 校验组合成员类型数量是否小于等于指定的最大值 *** -#### func WithValidatorHandleTypeLengthNot(length int, getType func (item T) E) ValidatorOption[T] +#### func WithValidatorHandleTypeLengthNot(length int, getType func (item T) E) ValidatorOption[T] > 校验组合成员类型数量是否不等于指定的值 *** -#### func WithValidatorHandleContinuous(getIndex func (item T) Index) ValidatorOption[T] +#### func WithValidatorHandleContinuous(getIndex func (item T) Index) ValidatorOption[T] > 校验组合成员是否连续 *** -#### func WithValidatorHandleContinuousNot(getIndex func (item T) Index) ValidatorOption[T] +#### func WithValidatorHandleContinuousNot(getIndex func (item T) Index) ValidatorOption[T] > 校验组合成员是否不连续 *** -#### func WithValidatorHandleGroupContinuous(getType func (item T) E, getIndex func (item T) Index) ValidatorOption[T] +#### func WithValidatorHandleGroupContinuous(getType func (item T) E, getIndex func (item T) Index) ValidatorOption[T] > 校验组合成员是否能够按类型分组并且连续 *** -#### func WithValidatorHandleGroupContinuousN(n int, getType func (item T) E, getIndex func (item T) Index) ValidatorOption[T] +#### func WithValidatorHandleGroupContinuousN(n int, getType func (item T) E, getIndex func (item T) Index) ValidatorOption[T] > 校验组合成员是否能够按分组为 n 组类型并且连续 *** -#### func WithValidatorHandleNCarryM(n int, m int, getType func (item T) E) ValidatorOption[T] +#### func WithValidatorHandleNCarryM(n int, m int, getType func (item T) E) ValidatorOption[T] > 校验组合成员是否匹配 N 携带相同的 M 的组合 > - n: 组合中元素的数量,表示需要匹配的组合数量,n 的类型需要全部相同 @@ -233,7 +233,7 @@ combination 包提供了一些实用的组合函数。 > - getType: 用于获取组合中元素的类型,用于判断是否相同 *** -#### func WithValidatorHandleNCarryIndependentM(n int, m int, getType func (item T) E) ValidatorOption[T] +#### func WithValidatorHandleNCarryIndependentM(n int, m int, getType func (item T) E) ValidatorOption[T] > 校验组合成员是否匹配 N 携带独立的 M 的组合 > - n: 组合中元素的数量,表示需要匹配的组合数量,n 的类型需要全部相同 diff --git a/utils/compress/README.md b/utils/compress/README.md index d576d74..03f09b7 100644 --- a/utils/compress/README.md +++ b/utils/compress/README.md @@ -30,32 +30,32 @@ compress 提供了一些用于压缩和解压缩数据的函数。 *** ## 详情信息 -#### func GZipCompress(data []byte) bytes.Buffer, error +#### func GZipCompress(data []byte) (bytes.Buffer, error) > 对数据进行GZip压缩,返回bytes.Buffer和错误信息 *** -#### func GZipUnCompress(dataByte []byte) []byte, error +#### func GZipUnCompress(dataByte []byte) ([]byte, error) > 对已进行GZip压缩的数据进行解压缩,返回字节数组及错误信息 *** -#### func TARCompress(data []byte) bytes.Buffer, error +#### func TARCompress(data []byte) (bytes.Buffer, error) > 对数据进行TAR压缩,返回bytes.Buffer和错误信息 *** -#### func TARUnCompress(dataByte []byte) []byte, error +#### func TARUnCompress(dataByte []byte) ([]byte, error) > 对已进行TAR压缩的数据进行解压缩,返回字节数组及错误信息 *** -#### func ZIPCompress(data []byte) bytes.Buffer, error +#### func ZIPCompress(data []byte) (bytes.Buffer, error) > 对数据进行ZIP压缩,返回bytes.Buffer和错误信息 *** -#### func ZIPUnCompress(dataByte []byte) []byte, error +#### func ZIPUnCompress(dataByte []byte) ([]byte, error) > 对已进行ZIP压缩的数据进行解压缩,返回字节数组及错误信息 diff --git a/utils/crypto/README.md b/utils/crypto/README.md index 88f6719..4864232 100644 --- a/utils/crypto/README.md +++ b/utils/crypto/README.md @@ -34,52 +34,52 @@ *** ## 详情信息 -#### func EncryptBase64(data []byte) string +#### func EncryptBase64(data []byte) string > 对数据进行Base64编码 *** -#### func DecodedBase64(data string) []byte, error +#### func DecodedBase64(data string) ([]byte, error) > 对数据进行Base64解码 *** -#### func EncryptCRC32(str string) uint32 +#### func EncryptCRC32(str string) uint32 > 对字符串进行CRC加密并返回其结果。 *** -#### func DecodedCRC32(data []byte) uint32 +#### func DecodedCRC32(data []byte) uint32 > 对字节数组进行CRC加密并返回其结果。 *** -#### func EncryptMD5(str string) string +#### func EncryptMD5(str string) string > 对字符串进行MD5加密并返回其结果。 *** -#### func DecodedMD5(data []byte) string +#### func DecodedMD5(data []byte) string > 对字节数组进行MD5加密并返回其结果。 *** -#### func EncryptSHA1(str string) string +#### func EncryptSHA1(str string) string > 对字符串进行SHA1加密并返回其结果。 *** -#### func DecodedSHA1(data []byte) string +#### func DecodedSHA1(data []byte) string > 对字节数组进行SHA1加密并返回其结果。 *** -#### func EncryptSHA256(str string) string +#### func EncryptSHA256(str string) string > 对字符串进行SHA256加密并返回其结果。 *** -#### func DecodedSHA256(data []byte) string +#### func DecodedSHA256(data []byte) string > 对字节数组进行SHA256加密并返回其结果。 diff --git a/utils/deck/README.md b/utils/deck/README.md index f6f342d..3c95f23 100644 --- a/utils/deck/README.md +++ b/utils/deck/README.md @@ -33,12 +33,12 @@ deck 包中的内容用于针对一堆内容的管理,适用但不限于牌堆 *** ## 详情信息 -#### func NewDeck() *Deck[I] +#### func NewDeck() *Deck[I] > 创建一个新的甲板 *** -#### func NewGroup(guid int64, fillHandle func (guid int64) []I) *Group[I] +#### func NewGroup(guid int64, fillHandle func (guid int64) []I) *Group[I] > 创建一个新的组 diff --git a/utils/file/README.md b/utils/file/README.md index aa2cf96..fc7e257 100644 --- a/utils/file/README.md +++ b/utils/file/README.md @@ -35,46 +35,46 @@ *** ## 详情信息 -#### func PathExist(path string) bool, error +#### func PathExist(path string) (bool, error) > 路径是否存在 *** -#### func IsDir(path string) bool, error +#### func IsDir(path string) (bool, error) > 路径是否是文件夹 *** -#### func WriterFile(filePath string, content []byte) error +#### func WriterFile(filePath string, content []byte) error > 向特定文件写入内容 *** -#### func ReadOnce(filePath string) []byte, error +#### func ReadOnce(filePath string) ([]byte, error) > 单次读取文件 > - 一次性对整个文件进行读取,小文件读取可以很方便的一次性将文件内容读取出来,而大文件读取会造成性能影响。 *** -#### func ReadBlockHook(filePath string, bufferSize int, hook func (data []byte)) error +#### func ReadBlockHook(filePath string, bufferSize int, hook func (data []byte)) error > 分块读取文件 > - 将filePath路径对应的文件数据并将读到的每一部分传入hook函数中,当过程中如果产生错误则会返回error。 > - 分块读取可以在读取速度和内存消耗之间有一个很好的平衡。 *** -#### func ReadLine(filePath string, hook func (line string)) error +#### func ReadLine(filePath string, hook func (line string)) error > 分行读取文件 > - 将filePath路径对应的文件数据并将读到的每一行传入hook函数中,当过程中如果产生错误则会返回error。 *** -#### func LineCount(filePath string) int +#### func LineCount(filePath string) int > 统计文件行数 *** -#### func Paths(dir string) []string +#### func Paths(dir string) []string > 获取指定目录下的所有文件路径 > - 包括了子目录下的文件 @@ -88,7 +88,7 @@ > - 可通过 start 参数指定开始读取的位置,如果不指定则从文件开头开始读取。 *** -#### func FindLineChunks(file *os.File, chunkSize int64) [][2]int64 +#### func FindLineChunks(file *os.File, chunkSize int64) [][2]int64 > 查找文件按照每行划分的分块,每个分块的大小将在 chunkSize 和分割后的分块距离行首及行尾的距离中范围内 > - 使用该函数得到的分块是完整的行,不会出现行被分割的情况 @@ -96,7 +96,7 @@ > - 返回值的成员是一个长度为 2 的数组,第一个元素是分块的起始位置,第二个元素是分块的结束位置 *** -#### func FindLineChunksByOffset(file *os.File, offset int64, chunkSize int64) [][2]int64 +#### func FindLineChunksByOffset(file *os.File, offset int64, chunkSize int64) [][2]int64 > 该函数与 FindLineChunks 类似,不同的是该函数可以指定 offset 从指定位置开始读取文件 diff --git a/utils/fsm/README.md b/utils/fsm/README.md index f19ad85..0661ad2 100644 --- a/utils/fsm/README.md +++ b/utils/fsm/README.md @@ -36,34 +36,34 @@ *** ## 详情信息 -#### func NewFSM(data Data) *FSM[State, Data] +#### func NewFSM(data Data) *FSM[State, Data] > 创建一个新的状态机 *** -#### func WithEnterBeforeEvent(fn func (state *FSM[State, Data])) Option[State, Data] +#### func WithEnterBeforeEvent(fn func (state *FSM[State, Data])) Option[State, Data] > 设置状态进入前的回调 > - 在首次设置状态时,状态机本身的当前状态为零值状态 *** -#### func WithEnterAfterEvent(fn func (state *FSM[State, Data])) Option[State, Data] +#### func WithEnterAfterEvent(fn func (state *FSM[State, Data])) Option[State, Data] > 设置状态进入后的回调 *** -#### func WithUpdateEvent(fn func (state *FSM[State, Data])) Option[State, Data] +#### func WithUpdateEvent(fn func (state *FSM[State, Data])) Option[State, Data] > 设置状态内刷新的回调 *** -#### func WithExitBeforeEvent(fn func (state *FSM[State, Data])) Option[State, Data] +#### func WithExitBeforeEvent(fn func (state *FSM[State, Data])) Option[State, Data] > 设置状态退出前的回调 > - 该阶段状态机的状态为退出前的状态,而非新的状态 *** -#### func WithExitAfterEvent(fn func (state *FSM[State, Data])) Option[State, Data] +#### func WithExitAfterEvent(fn func (state *FSM[State, Data])) Option[State, Data] > 设置状态退出后的回调 > - 该阶段状态机的状态为新的状态,而非退出前的状态 diff --git a/utils/generator/astgo/README.md b/utils/generator/astgo/README.md index 282a53c..a8edb18 100644 --- a/utils/generator/astgo/README.md +++ b/utils/generator/astgo/README.md @@ -36,7 +36,7 @@ *** ## 详情信息 -#### func NewPackage(dir string) *Package, error +#### func NewPackage(dir string) (*Package, error)
diff --git a/utils/generator/genreadme/README.md b/utils/generator/genreadme/README.md index e4851ac..6ead52e 100644 --- a/utils/generator/genreadme/README.md +++ b/utils/generator/genreadme/README.md @@ -30,7 +30,7 @@ *** ## 详情信息 -#### func New(pkgDirPath string, output string) *Builder, error +#### func New(pkgDirPath string, output string) (*Builder, error) *** @@ -51,11 +51,11 @@ type Builder struct { ```go func TestBuilder_Generate(t *testing.T) { - filepath.Walk("/Users/kercylan/Coding.localized/Go/minotaur", func(path string, info fs.FileInfo, err error) error { + filepath.Walk("D:/sources/minotaur", func(path string, info fs.FileInfo, err error) error { if !info.IsDir() { return nil } - if strings.Contains(strings.TrimPrefix(path, "/Users/kercylan/Coding.localized/Go/minotaur"), ".") { + if strings.Contains(strings.TrimPrefix(path, "D:/sources/minotaur"), ".") { return nil } b, err := New(path, filepath.Join(path, "README.md")) diff --git a/utils/generator/genreadme/builder.go b/utils/generator/genreadme/builder.go index 06cf694..343656b 100644 --- a/utils/generator/genreadme/builder.go +++ b/utils/generator/genreadme/builder.go @@ -163,7 +163,13 @@ func (b *Builder) genStructs() { } return f }(), - funcHandler(function.Results), + func() string { + f := strings.TrimSpace(funcHandler(function.Results)) + if len(function.Results) >= 2 && !strings.HasPrefix(f, "(") { + f = "(" + f + ")" + } + return f + }(), ))) b.newLine(fmt.Sprintf(``, function.Name)) b.quote() @@ -260,7 +266,13 @@ func (b *Builder) genStructs() { } return f }(), - funcHandler(function.Results), + func() string { + f := funcHandler(function.Results) + if len(function.Results) >= 2 && !strings.HasPrefix(strings.TrimSpace(f), "(") { + f = "(" + f + ")" + } + return f + }(), ))) b.quote() for _, comment := range function.Comments.Clear { diff --git a/utils/generator/genreadme/builder_test.go b/utils/generator/genreadme/builder_test.go index 9a420ab..ded811b 100644 --- a/utils/generator/genreadme/builder_test.go +++ b/utils/generator/genreadme/builder_test.go @@ -16,11 +16,11 @@ func TestBuilder_Generate(t *testing.T) { // panic(err) //} //return - filepath.Walk("/Users/kercylan/Coding.localized/Go/minotaur", func(path string, info fs.FileInfo, err error) error { + filepath.Walk("D:/sources/minotaur", func(path string, info fs.FileInfo, err error) error { if !info.IsDir() { return nil } - if strings.Contains(strings.TrimPrefix(path, "/Users/kercylan/Coding.localized/Go/minotaur"), ".") { + if strings.Contains(strings.TrimPrefix(path, "D:/sources/minotaur"), ".") { return nil } b, err := New( diff --git a/utils/generic/README.md b/utils/generic/README.md index c57f517..90c71d6 100644 --- a/utils/generic/README.md +++ b/utils/generic/README.md @@ -48,17 +48,17 @@ generic 目的在于提供一组基于泛型的用于处理通用功能的函数 *** ## 详情信息 -#### func IsNil(v V) bool +#### func IsNil(v V) bool > 检查指定的值是否为 nil *** -#### func IsAllNil(v ...V) bool +#### func IsAllNil(v ...V) bool > 检查指定的值是否全部为 nil *** -#### func IsHasNil(v ...V) bool +#### func IsHasNil(v ...V) bool > 检查指定的值是否存在 nil diff --git a/utils/geometry/README.md b/utils/geometry/README.md index 177eb01..1d3055e 100644 --- a/utils/geometry/README.md +++ b/utils/geometry/README.md @@ -132,7 +132,7 @@ geometry 旨在提供一组用于处理几何形状和计算几何属性的函 *** ## 详情信息 -#### func NewCircle(radius V, points int) Circle[V] +#### func NewCircle(radius V, points int) Circle[V] > 通过传入圆的半径和需要的点数量,生成一个圆 @@ -146,12 +146,12 @@ func ExampleNewCircle() { ``` *** -#### func CalcCircleCentroidDistance(circle1 Circle[V], circle2 Circle[V]) V +#### func CalcCircleCentroidDistance(circle1 Circle[V], circle2 Circle[V]) V > 计算两个圆质心距离 *** -#### func GetOppositionDirection(direction Direction) Direction +#### func GetOppositionDirection(direction Direction) Direction > 获取特定方向的对立方向 @@ -161,39 +161,39 @@ func ExampleNewCircle() { > 获取特定方向上的下一个坐标 *** -#### func GetDirectionNextWithPoint(direction Direction, point Point[V]) Point[V] +#### func GetDirectionNextWithPoint(direction Direction, point Point[V]) Point[V] > 获取特定方向上的下一个坐标 *** -#### func GetDirectionNextWithPos(direction Direction, width V, pos V) V +#### func GetDirectionNextWithPos(direction Direction, width V, pos V) V > 获取位置在特定宽度和特定方向上的下一个位置 > - 需要注意的是,在左右方向时,当下一个位置不在矩形区域内时,将会返回上一行的末位置或下一行的首位置 *** -#### func CalcDirection(x1 V, y1 V, x2 V, y2 V) Direction +#### func CalcDirection(x1 V, y1 V, x2 V, y2 V) Direction > 计算点2位于点1的方向 *** -#### func CalcDistanceWithCoordinate(x1 V, y1 V, x2 V, y2 V) V +#### func CalcDistanceWithCoordinate(x1 V, y1 V, x2 V, y2 V) V > 计算两点之间的距离 *** -#### func CalcDistanceWithPoint(point1 Point[V], point2 Point[V]) V +#### func CalcDistanceWithPoint(point1 Point[V], point2 Point[V]) V > 计算两点之间的距离 *** -#### func CalcDistanceSquared(x1 V, y1 V, x2 V, y2 V) V +#### func CalcDistanceSquared(x1 V, y1 V, x2 V, y2 V) V > 计算两点之间的平方距离 > - 这个函数的主要用途是在需要计算两点之间距离的情况下,但不需要得到实际的距离值,而只需要比较距离大小。因为平方根运算相对较为耗时,所以在只需要比较大小的情况下,通常会使用平方距离。 *** -#### func CalcAngle(x1 V, y1 V, x2 V, y2 V) V +#### func CalcAngle(x1 V, y1 V, x2 V, y2 V) V > 计算点2位于点1之间的角度 @@ -203,75 +203,75 @@ func ExampleNewCircle() { > 根据给定的x、y坐标、角度和距离计算新的坐标 *** -#### func CalcRadianWithAngle(angle V) V +#### func CalcRadianWithAngle(angle V) V > 根据角度 angle 计算弧度 *** -#### func CalcAngleDifference(angleA V, angleB V) V +#### func CalcAngleDifference(angleA V, angleB V) V > 计算两个角度之间的最小角度差 *** -#### func CalcRayIsIntersect(x V, y V, angle V, shape Shape[V]) bool +#### func CalcRayIsIntersect(x V, y V, angle V, shape Shape[V]) bool > 根据给定的位置和角度生成射线,检测射线是否与多边形发生碰撞 *** -#### func NewLineSegment(start Point[V], end Point[V]) LineSegment[V] +#### func NewLineSegment(start Point[V], end Point[V]) LineSegment[V] > 创建一根线段 *** -#### func NewLineSegmentCap(start Point[V], end Point[V], data Data) LineSegmentCap[V, Data] +#### func NewLineSegmentCap(start Point[V], end Point[V], data Data) LineSegmentCap[V, Data] > 创建一根包含数据的线段 *** -#### func NewLineSegmentCapWithLine(line LineSegment[V], data Data) LineSegmentCap[V, Data] +#### func NewLineSegmentCapWithLine(line LineSegment[V], data Data) LineSegmentCap[V, Data] > 通过已有线段创建一根包含数据的线段 *** -#### func ConvertLineSegmentGeneric(line LineSegment[V]) LineSegment[TO] +#### func ConvertLineSegmentGeneric(line LineSegment[V]) LineSegment[TO] > 转换线段的泛型类型为特定类型 *** -#### func PointOnLineSegmentWithCoordinate(x1 V, y1 V, x2 V, y2 V, x V, y V) bool +#### func PointOnLineSegmentWithCoordinate(x1 V, y1 V, x2 V, y2 V, x V, y V) bool > 通过一个线段两个点的位置和一个点的坐标,判断这个点是否在一条线段上 *** -#### func PointOnLineSegmentWithPos(width V, pos1 V, pos2 V, pos V) bool +#### func PointOnLineSegmentWithPos(width V, pos1 V, pos2 V, pos V) bool > 通过一个线段两个点的位置和一个点的坐标,判断这个点是否在一条线段上 *** -#### func PointOnLineSegmentWithPoint(point1 Point[V], point2 Point[V], point Point[V]) bool +#### func PointOnLineSegmentWithPoint(point1 Point[V], point2 Point[V], point Point[V]) bool > 通过一个线段两个点的位置和一个点的坐标,判断这个点是否在一条线段上 *** -#### func PointOnLineSegmentWithCoordinateInBounds(x1 V, y1 V, x2 V, y2 V, x V, y V) bool +#### func PointOnLineSegmentWithCoordinateInBounds(x1 V, y1 V, x2 V, y2 V, x V, y V) bool > 通过一个线段两个点的位置和一个点的坐标,判断这个点是否在一条线段上 > - 与 PointOnLineSegmentWithCoordinate 不同的是, PointOnLineSegmentWithCoordinateInBounds 中会判断线段及点的位置是否正确 *** -#### func PointOnLineSegmentWithPosInBounds(width V, pos1 V, pos2 V, pos V) bool +#### func PointOnLineSegmentWithPosInBounds(width V, pos1 V, pos2 V, pos V) bool > 通过一个线段两个点的位置和一个点的坐标,判断这个点是否在一条线段上 > - 与 PointOnLineSegmentWithPos 不同的是, PointOnLineSegmentWithPosInBounds 中会判断线段及点的位置是否正确 *** -#### func PointOnLineSegmentWithPointInBounds(point1 Point[V], point2 Point[V], point Point[V]) bool +#### func PointOnLineSegmentWithPointInBounds(point1 Point[V], point2 Point[V], point Point[V]) bool > 通过一个线段两个点的位置和一个点的坐标,判断这个点是否在一条线段上 > - 与 PointOnLineSegmentWithPoint 不同的是, PointOnLineSegmentWithPointInBounds 中会判断线段及点的位置是否正确 *** -#### func CalcLineSegmentIsCollinear(line1 LineSegment[V], line2 LineSegment[V], tolerance V) bool +#### func CalcLineSegmentIsCollinear(line1 LineSegment[V], line2 LineSegment[V], tolerance V) bool > 检查两条线段在一个误差内是否共线 > - 共线是指两条线段在同一直线上,即它们的延长线可以重合 @@ -282,7 +282,7 @@ func ExampleNewCircle() { > 通过对点进行排序来检查两条共线线段是否重叠,返回重叠线段 *** -#### func CalcLineSegmentIsIntersect(line1 LineSegment[V], line2 LineSegment[V]) bool +#### func CalcLineSegmentIsIntersect(line1 LineSegment[V], line2 LineSegment[V]) bool > 计算两条线段是否相交 @@ -305,17 +305,17 @@ func TestCalcLineSegmentIsIntersect(t *testing.T) { *** -#### func CalcLineSegmentSlope(line LineSegment[V]) V +#### func CalcLineSegmentSlope(line LineSegment[V]) V > 计算线段的斜率 *** -#### func CalcLineSegmentIntercept(line LineSegment[V]) V +#### func CalcLineSegmentIntercept(line LineSegment[V]) V > 计算线段的截距 *** -#### func NewPoint(x V, y V) Point[V] +#### func NewPoint(x V, y V) Point[V] > 创建一个由 x、y 坐标组成的点 @@ -337,27 +337,27 @@ func TestNewPoint(t *testing.T) { *** -#### func NewPointCap(x V, y V) PointCap[V, D] +#### func NewPointCap(x V, y V) PointCap[V, D] > 创建一个由 x、y 坐标组成的点,这个点具有一个数据容量 *** -#### func NewPointCapWithData(x V, y V, data D) PointCap[V, D] +#### func NewPointCapWithData(x V, y V, data D) PointCap[V, D] > 通过设置数据的方式创建一个由 x、y 坐标组成的点,这个点具有一个数据容量 *** -#### func NewPointCapWithPoint(point Point[V], data D) PointCap[V, D] +#### func NewPointCapWithPoint(point Point[V], data D) PointCap[V, D] > 通过设置数据的方式创建一个由已有坐标组成的点,这个点具有一个数据容量 *** -#### func CoordinateToPoint(x V, y V) Point[V] +#### func CoordinateToPoint(x V, y V) Point[V] > 将坐标转换为x、y的坐标数组 *** -#### func CoordinateToPos(width V, x V, y V) V +#### func CoordinateToPos(width V, x V, y V) V > 将坐标转换为二维数组的顺序位置坐标 > - 需要确保x的取值范围必须小于width,或者将会得到不正确的值 @@ -368,7 +368,7 @@ func TestNewPoint(t *testing.T) { > 将坐标数组转换为x和y坐标 *** -#### func PointToPos(width V, xy Point[V]) V +#### func PointToPos(width V, xy Point[V]) V > 将坐标转换为二维数组的顺序位置 > - 需要确保x的取值范围必须小于width,或者将会得到不正确的值 @@ -379,38 +379,38 @@ func TestNewPoint(t *testing.T) { > 通过宽度将一个二维数组的顺序位置转换为xy坐标 *** -#### func PosToPoint(width V, pos V) Point[V] +#### func PosToPoint(width V, pos V) Point[V] > 通过宽度将一个二维数组的顺序位置转换为x、y的坐标数组 *** -#### func PosToCoordinateX(width V, pos V) V +#### func PosToCoordinateX(width V, pos V) V > 通过宽度将一个二维数组的顺序位置转换为X坐标 *** -#### func PosToCoordinateY(width V, pos V) V +#### func PosToCoordinateY(width V, pos V) V > 通过宽度将一个二维数组的顺序位置转换为Y坐标 *** -#### func PointCopy(point Point[V]) Point[V] +#### func PointCopy(point Point[V]) Point[V] > 复制一个坐标数组 *** -#### func PointToPosWithMulti(width V, points ...Point[V]) []V +#### func PointToPosWithMulti(width V, points ...Point[V]) []V > 将一组坐标转换为二维数组的顺序位置 > - 需要确保x的取值范围必须小于width,或者将会得到不正确的值 *** -#### func PosToPointWithMulti(width V, positions ...V) []Point[V] +#### func PosToPointWithMulti(width V, positions ...V) []Point[V] > 将一组二维数组的顺序位置转换为一组数组坐标 *** -#### func PosSameRow(width V, pos1 V, pos2 V) bool +#### func PosSameRow(width V, pos1 V, pos2 V) bool > 返回两个顺序位置在同一宽度是否位于同一行 @@ -420,7 +420,7 @@ func TestNewPoint(t *testing.T) { > 将两个位置转换为 x1, y1, x2, y2 的坐标进行返回 *** -#### func CalcProjectionPoint(line LineSegment[V], point Point[V]) Point[V] +#### func CalcProjectionPoint(line LineSegment[V], point Point[V]) Point[V] > 计算一个点到一条线段的最近点(即投影点)的。这个函数接收一个点和一条线段作为输入,线段由两个端点组成。 > - 该函数的主要用于需要计算一个点到一条线段的最近点的情况下 @@ -675,7 +675,7 @@ func TestGenerateShapeOnRectangle(t *testing.T) { > 获取一个矩形填充满后包含的所有位置 *** -#### func CalcRectangleCentroid(shape Shape[V]) Point[V] +#### func CalcRectangleCentroid(shape Shape[V]) Point[V] > 计算矩形质心 > - 非多边形质心计算,仅为顶点的平均值 - 该区域中多边形因子的适当质心 @@ -691,7 +691,7 @@ func TestGenerateShapeOnRectangle(t *testing.T) { > 设置 Shape.String 是没有边界的 *** -#### func NewShape(points ...Point[V]) Shape[V] +#### func NewShape(points ...Point[V]) Shape[V] > 通过多个点生成一个形状进行返回 @@ -775,91 +775,91 @@ func TestNewShapeWithString(t *testing.T) { *** -#### func CalcBoundingRadius(shape Shape[V]) V +#### func CalcBoundingRadius(shape Shape[V]) V > 计算多边形转换为圆的半径 *** -#### func CalcBoundingRadiusWithCentroid(shape Shape[V], centroid Point[V]) V +#### func CalcBoundingRadiusWithCentroid(shape Shape[V], centroid Point[V]) V > 计算多边形在特定质心下圆的半径 *** -#### func CalcTriangleTwiceArea(a Point[V], b Point[V], c Point[V]) V +#### func CalcTriangleTwiceArea(a Point[V], b Point[V], c Point[V]) V > 计算由 a、b、c 三个点组成的三角形的面积的两倍 *** -#### func IsPointOnEdge(edges []LineSegment[V], point Point[V]) bool +#### func IsPointOnEdge(edges []LineSegment[V], point Point[V]) bool > 检查点是否在 edges 的任意一条边上 *** -#### func ProjectionPointToShape(point Point[V], shape Shape[V]) Point[V], V +#### func ProjectionPointToShape(point Point[V], shape Shape[V]) (Point[V], V) > 将一个点投影到一个多边形上,找到离该点最近的投影点,并返回投影点和距离 *** -#### func WithShapeSearchRectangleLowerLimit(minWidth int, minHeight int) ShapeSearchOption +#### func WithShapeSearchRectangleLowerLimit(minWidth int, minHeight int) ShapeSearchOption > 通过矩形宽高下限的方式搜索 *** -#### func WithShapeSearchRectangleUpperLimit(maxWidth int, maxHeight int) ShapeSearchOption +#### func WithShapeSearchRectangleUpperLimit(maxWidth int, maxHeight int) ShapeSearchOption > 通过矩形宽高上限的方式搜索 *** -#### func WithShapeSearchRightAngle() ShapeSearchOption +#### func WithShapeSearchRightAngle() ShapeSearchOption > 通过直角的方式进行搜索 *** -#### func WithShapeSearchOppositionDirection(direction Direction) ShapeSearchOption +#### func WithShapeSearchOppositionDirection(direction Direction) ShapeSearchOption > 通过限制对立方向的方式搜索 > - 对立方向例如上不能与下共存 *** -#### func WithShapeSearchDirectionCount(count int) ShapeSearchOption +#### func WithShapeSearchDirectionCount(count int) ShapeSearchOption > 通过限制方向数量的方式搜索 *** -#### func WithShapeSearchDirectionCountLowerLimit(direction Direction, count int) ShapeSearchOption +#### func WithShapeSearchDirectionCountLowerLimit(direction Direction, count int) ShapeSearchOption > 通过限制特定方向数量下限的方式搜索 *** -#### func WithShapeSearchDirectionCountUpperLimit(direction Direction, count int) ShapeSearchOption +#### func WithShapeSearchDirectionCountUpperLimit(direction Direction, count int) ShapeSearchOption > 通过限制特定方向数量上限的方式搜索 *** -#### func WithShapeSearchDeduplication() ShapeSearchOption +#### func WithShapeSearchDeduplication() ShapeSearchOption > 通过去重的方式进行搜索 > - 去重方式中每个点仅会被使用一次 *** -#### func WithShapeSearchPointCountLowerLimit(lowerLimit int) ShapeSearchOption +#### func WithShapeSearchPointCountLowerLimit(lowerLimit int) ShapeSearchOption > 通过限制图形构成的最小点数进行搜索 > - 当搜索到的图形的点数量低于 lowerLimit 时,将被忽略 *** -#### func WithShapeSearchPointCountUpperLimit(upperLimit int) ShapeSearchOption +#### func WithShapeSearchPointCountUpperLimit(upperLimit int) ShapeSearchOption > 通过限制图形构成的最大点数进行搜索 > - 当搜索到的图形的点数量大于 upperLimit 时,将被忽略 *** -#### func WithShapeSearchAsc() ShapeSearchOption +#### func WithShapeSearchAsc() ShapeSearchOption > 通过升序的方式进行搜索 *** -#### func WithShapeSearchDesc() ShapeSearchOption +#### func WithShapeSearchDesc() ShapeSearchOption > 通过降序的方式进行搜索 diff --git a/utils/geometry/astar/README.md b/utils/geometry/astar/README.md index 100b4ad..c8e8540 100644 --- a/utils/geometry/astar/README.md +++ b/utils/geometry/astar/README.md @@ -35,7 +35,7 @@ astar 提供用于实现 A* 算法的函数和数据结构。A* 算法是一种 *** ## 详情信息 -#### func Find(graph Graph[Node], start Node, end Node, cost func (a Node) V, heuristic func (a Node) V) []Node +#### func Find(graph Graph[Node], start Node, end Node, cost func (a Node) V, heuristic func (a Node) V) []Node > 使用 A* 算法在导航网格上查找从起点到终点的最短路径,并返回路径上的节点序列。 > diff --git a/utils/geometry/dp/README.md b/utils/geometry/dp/README.md index 5be6dee..3b22ddc 100644 --- a/utils/geometry/dp/README.md +++ b/utils/geometry/dp/README.md @@ -35,7 +35,7 @@ dp (DistributionPattern) 提供用于在二维数组中根据不同的特征标 *** ## 详情信息 -#### func NewDistributionPattern(sameKindVerifyHandle func (itemA Item) bool) *DistributionPattern[Item] +#### func NewDistributionPattern(sameKindVerifyHandle func (itemA Item) bool) *DistributionPattern[Item] > 构建一个分布图实例 diff --git a/utils/geometry/matrix/README.md b/utils/geometry/matrix/README.md index 0981cdf..691e139 100644 --- a/utils/geometry/matrix/README.md +++ b/utils/geometry/matrix/README.md @@ -30,7 +30,7 @@ matrix 提供了一个简单的二维数组的实现 *** ## 详情信息 -#### func NewMatrix(width int, height int) *Matrix[T] +#### func NewMatrix(width int, height int) *Matrix[T] > 生成特定宽高的二维矩阵 > - 虽然提供了通过x、y坐标的操作函数,但是建议无论如何使用pos进行处理 diff --git a/utils/geometry/navmesh/README.md b/utils/geometry/navmesh/README.md index 0374f76..9bdab61 100644 --- a/utils/geometry/navmesh/README.md +++ b/utils/geometry/navmesh/README.md @@ -33,7 +33,7 @@ navmesh 提供了用于导航网格处理的函数和数据结构。导航网格 *** ## 详情信息 -#### func NewNavMesh(shapes []geometry.Shape[V], meshShrinkAmount V) *NavMesh[V] +#### func NewNavMesh(shapes []geometry.Shape[V], meshShrinkAmount V) *NavMesh[V] > 创建一个新的导航网格,并返回一个指向该导航网格的指针。 > diff --git a/utils/hub/README.md b/utils/hub/README.md index 3bb9577..d350d93 100644 --- a/utils/hub/README.md +++ b/utils/hub/README.md @@ -30,7 +30,7 @@ *** ## 详情信息 -#### func NewObjectPool(generator func () *T, releaser func (data *T)) *ObjectPool[*T] +#### func NewObjectPool(generator func () *T, releaser func (data *T)) *ObjectPool[*T] > 创建一个 ObjectPool diff --git a/utils/huge/README.md b/utils/huge/README.md index 54c94c7..0a762ce 100644 --- a/utils/huge/README.md +++ b/utils/huge/README.md @@ -34,23 +34,23 @@ *** ## 详情信息 -#### func NewFloat(x T) *Float +#### func NewFloat(x T) *Float > 创建一个 Float *** -#### func NewFloatByString(i string) *Float +#### func NewFloatByString(i string) *Float > 通过字符串创建一个 Float > - 如果字符串不是一个合法的数字,则返回 0 *** -#### func NewInt(x T) *Int +#### func NewInt(x T) *Int > 创建一个 Int *** -#### func NewIntByString(i string) *Int +#### func NewIntByString(i string) *Int > 通过字符串创建一个 Int > - 如果字符串不是一个合法的数字,则返回 0 diff --git a/utils/leaderboard/README.md b/utils/leaderboard/README.md index 6be6bd6..15bcb62 100644 --- a/utils/leaderboard/README.md +++ b/utils/leaderboard/README.md @@ -34,7 +34,7 @@ *** ## 详情信息 -#### func NewBinarySearch(options ...BinarySearchOption[CompetitorID, Score]) *BinarySearch[CompetitorID, Score] +#### func NewBinarySearch(options ...BinarySearchOption[CompetitorID, Score]) *BinarySearch[CompetitorID, Score] > 创建一个基于内存的二分查找排行榜 @@ -49,13 +49,13 @@ func ExampleNewBinarySearch() { ``` *** -#### func WithBinarySearchCount(rankCount int) BinarySearchOption[CompetitorID, Score] +#### func WithBinarySearchCount(rankCount int) BinarySearchOption[CompetitorID, Score] > 通过限制排行榜竞争者数量来创建排行榜 > - 默认情况下允许100位竞争者 *** -#### func WithBinarySearchASC() BinarySearchOption[CompetitorID, Score] +#### func WithBinarySearchASC() BinarySearchOption[CompetitorID, Score] > 通过升序的方式创建排行榜 > - 默认情况下为降序 diff --git a/utils/log/README.md b/utils/log/README.md index 7980ed3..37be9bb 100644 --- a/utils/log/README.md +++ b/utils/log/README.md @@ -96,7 +96,7 @@ *** -#### func Default() *Logger +#### func Default() *Logger > 获取默认的日志记录器 @@ -150,193 +150,193 @@ > - 然后记录器调用 os.Exit(1),即使 FatalLevel 的日志记录被禁用 *** -#### func Skip(vs ...any) slog.Attr +#### func Skip(vs ...any) slog.Attr > 构造一个无操作字段,这在处理其他 Field 构造函数中的无效输入时通常很有用 > - 该函数还支持将其他字段快捷的转换为 Skip 字段 *** -#### func Duration(key string, val time.Duration) slog.Attr +#### func Duration(key string, val time.Duration) slog.Attr > 使用给定的键和值构造一个字段。编码器控制持续时间的序列化方式 *** -#### func DurationP(key string, val *time.Duration) slog.Attr +#### func DurationP(key string, val *time.Duration) slog.Attr > 构造一个带有 time.Duration 的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Bool(key string, val bool) slog.Attr +#### func Bool(key string, val bool) slog.Attr > 构造一个带有布尔值的字段 *** -#### func BoolP(key string, val *bool) slog.Attr +#### func BoolP(key string, val *bool) slog.Attr > 构造一个带有布尔值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func String(key string, val string) slog.Attr +#### func String(key string, val string) slog.Attr > 构造一个带有字符串值的字段 *** -#### func StringP(key string, val *string) slog.Attr +#### func StringP(key string, val *string) slog.Attr > 构造一个带有字符串值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Int(key string, val I) slog.Attr +#### func Int(key string, val I) slog.Attr > 构造一个带有整数值的字段 *** -#### func IntP(key string, val *I) slog.Attr +#### func IntP(key string, val *I) slog.Attr > 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Int8(key string, val I) slog.Attr +#### func Int8(key string, val I) slog.Attr > 构造一个带有整数值的字段 *** -#### func Int8P(key string, val *I) slog.Attr +#### func Int8P(key string, val *I) slog.Attr > 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Int16(key string, val I) slog.Attr +#### func Int16(key string, val I) slog.Attr > 构造一个带有整数值的字段 *** -#### func Int16P(key string, val *I) slog.Attr +#### func Int16P(key string, val *I) slog.Attr > 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Int32(key string, val I) slog.Attr +#### func Int32(key string, val I) slog.Attr > 构造一个带有整数值的字段 *** -#### func Int32P(key string, val *I) slog.Attr +#### func Int32P(key string, val *I) slog.Attr > 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Int64(key string, val I) slog.Attr +#### func Int64(key string, val I) slog.Attr > 构造一个带有整数值的字段 *** -#### func Int64P(key string, val *I) slog.Attr +#### func Int64P(key string, val *I) slog.Attr > 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Uint(key string, val I) slog.Attr +#### func Uint(key string, val I) slog.Attr > 构造一个带有整数值的字段 *** -#### func UintP(key string, val *I) slog.Attr +#### func UintP(key string, val *I) slog.Attr > 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Uint8(key string, val I) slog.Attr +#### func Uint8(key string, val I) slog.Attr > 构造一个带有整数值的字段 *** -#### func Uint8P(key string, val *I) slog.Attr +#### func Uint8P(key string, val *I) slog.Attr > 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Uint16(key string, val I) slog.Attr +#### func Uint16(key string, val I) slog.Attr > 构造一个带有整数值的字段 *** -#### func Uint16P(key string, val *I) slog.Attr +#### func Uint16P(key string, val *I) slog.Attr > 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Uint32(key string, val I) slog.Attr +#### func Uint32(key string, val I) slog.Attr > 构造一个带有整数值的字段 *** -#### func Uint32P(key string, val *I) slog.Attr +#### func Uint32P(key string, val *I) slog.Attr > 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Uint64(key string, val I) slog.Attr +#### func Uint64(key string, val I) slog.Attr > 构造一个带有整数值的字段 *** -#### func Uint64P(key string, val *I) slog.Attr +#### func Uint64P(key string, val *I) slog.Attr > 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Float(key string, val F) slog.Attr +#### func Float(key string, val F) slog.Attr > 构造一个带有浮点值的字段 *** -#### func FloatP(key string, val *F) slog.Attr +#### func FloatP(key string, val *F) slog.Attr > 构造一个带有浮点值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Float32(key string, val F) slog.Attr +#### func Float32(key string, val F) slog.Attr > 构造一个带有浮点值的字段 *** -#### func Float32P(key string, val *F) slog.Attr +#### func Float32P(key string, val *F) slog.Attr > 构造一个带有浮点值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Float64(key string, val F) slog.Attr +#### func Float64(key string, val F) slog.Attr > 构造一个带有浮点值的字段 *** -#### func Float64P(key string, val *F) slog.Attr +#### func Float64P(key string, val *F) slog.Attr > 构造一个带有浮点值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Time(key string, val time.Time) slog.Attr +#### func Time(key string, val time.Time) slog.Attr > 构造一个带有时间值的字段 *** -#### func TimeP(key string, val *time.Time) slog.Attr +#### func TimeP(key string, val *time.Time) slog.Attr > 构造一个带有时间值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null" *** -#### func Any(key string, val any) slog.Attr +#### func Any(key string, val any) slog.Attr > 构造一个带有任意值的字段 *** -#### func Group(key string, args ...any) slog.Attr +#### func Group(key string, args ...any) slog.Attr > 返回分组字段 *** -#### func Stack(key string) slog.Attr +#### func Stack(key string) slog.Attr > 返回堆栈字段 @@ -368,27 +368,27 @@ func TestStack(t *testing.T) { *** -#### func Err(err error) slog.Attr +#### func Err(err error) slog.Attr > 构造一个带有错误值的字段 *** -#### func NewHandler(w io.Writer, opts *Options) slog.Handler +#### func NewHandler(w io.Writer, opts *Options) slog.Handler > 创建一个更偏向于人类可读的处理程序,该处理程序也是默认的处理程序 *** -#### func NewLogger(handlers ...slog.Handler) *Logger +#### func NewLogger(handlers ...slog.Handler) *Logger > 创建一个新的日志记录器 *** -#### func NewMultiHandler(handlers ...slog.Handler) slog.Handler +#### func NewMultiHandler(handlers ...slog.Handler) slog.Handler > 创建一个新的多处理程序 *** -#### func NewOptions() *Options +#### func NewOptions() *Options > 创建一个新的日志选项 diff --git a/utils/log/survey/README.md b/utils/log/survey/README.md index 7c2e721..5e05d6f 100644 --- a/utils/log/survey/README.md +++ b/utils/log/survey/README.md @@ -45,13 +45,13 @@ *** ## 详情信息 -#### func NewFileFlusher(filePath string, layout ...string) *FileFlusher +#### func NewFileFlusher(filePath string, layout ...string) *FileFlusher > 创建一个文件刷新器 > - layout 为日志文件名的时间戳格式 (默认为 time.DateOnly) *** -#### func WithFlushInterval(interval time.Duration) Option +#### func WithFlushInterval(interval time.Duration) Option > 设置日志文件刷新间隔 > - 默认为 3s,当日志文件刷新间隔 <= 0 时,将会在每次写入日志时刷新日志文件 @@ -83,19 +83,19 @@ > 关闭运营日志记录器 *** -#### func Analyze(filePath string, handle func (analyzer *Analyzer, record R)) *Report +#### func Analyze(filePath string, handle func (analyzer *Analyzer, record R)) *Report > 分析特定文件的记录,当发生错误时,会发生 panic > - handle 为并行执行的,需要自行处理并发安全 > - 适用于外部进程对于日志文件的读取,但是需要注意的是,此时日志文件可能正在被写入,所以可能会读取到错误的数据 *** -#### func AnalyzeMulti(filePaths []string, handle func (analyzer *Analyzer, record R)) *Report +#### func AnalyzeMulti(filePaths []string, handle func (analyzer *Analyzer, record R)) *Report > 与 Analyze 类似,但是可以分析多个文件 *** -#### func IncrementAnalyze(filePath string, handle func (analyzer *Analyzer, record R)) func () ( *Report, error) +#### func IncrementAnalyze(filePath string, handle func (analyzer *Analyzer, record R)) func () ( *Report, error) > 增量分析,返回一个函数,每次调用该函数都会分析文件中新增的内容 diff --git a/utils/maths/README.md b/utils/maths/README.md index 004d1fe..5d9170c 100644 --- a/utils/maths/README.md +++ b/utils/maths/README.md @@ -52,12 +52,12 @@ *** ## 详情信息 -#### func Compare(a V, expression CompareExpression, b V) bool +#### func Compare(a V, expression CompareExpression, b V) bool > 根据特定表达式比较两个值 *** -#### func IsContinuity(values S) bool +#### func IsContinuity(values S) bool > 检查一组值是否连续 @@ -72,32 +72,32 @@ func ExampleIsContinuity() { ``` *** -#### func IsContinuityWithSort(values S) bool +#### func IsContinuityWithSort(values S) bool > 检查一组值排序后是否连续 *** -#### func GetDefaultTolerance() float64 +#### func GetDefaultTolerance() float64 > 获取默认误差范围 *** -#### func Pow(a int, n int) int +#### func Pow(a int, n int) int > 整数幂运算 *** -#### func PowInt64(a int64, n int64) int64 +#### func PowInt64(a int64, n int64) int64 > 整数幂运算 *** -#### func Min(a V, b V) V +#### func Min(a V, b V) V > 返回两个数之中较小的值 *** -#### func Max(a V, b V) V +#### func Max(a V, b V) V > 返回两个数之中较大的值 @@ -112,17 +112,17 @@ func ExampleIsContinuity() { > 将两个数按照较大的和较小的顺序进行返回 *** -#### func Clamp(value V, min V, max V) V +#### func Clamp(value V, min V, max V) V > 将给定值限制在最小值和最大值之间 *** -#### func Tolerance(value1 V, value2 V, tolerance V) bool +#### func Tolerance(value1 V, value2 V, tolerance V) bool > 检查两个值是否在一个误差范围内 *** -#### func Merge(refer V, a V, b V) V +#### func Merge(refer V, a V, b V) V > 通过一个参考值合并两个数字 @@ -132,17 +132,17 @@ func ExampleIsContinuity() { > 通过一个参考值取消合并的两个数字 *** -#### func MergeToInt64(v1 V, v2 V) int64 +#### func MergeToInt64(v1 V, v2 V) int64 > 将两个数字合并为一个 int64 数字 *** -#### func UnMergeInt64(n int64) V, V +#### func UnMergeInt64(n int64) (V, V) > 将一个 int64 数字拆分为两个数字 *** -#### func ToContinuous(nums S) map[V]V +#### func ToContinuous(nums S) map[V]V > 将一组非连续的数字转换为从1开始的连续数字 > - 返回值是一个 map,key 是从 1 开始的连续数字,value 是原始数字 @@ -160,34 +160,34 @@ func ExampleToContinuous() { ``` *** -#### func CountDigits(num V) int +#### func CountDigits(num V) int > 接收一个整数 num 作为输入,并返回该数字的位数 *** -#### func GetDigitValue(num int64, digit int) int64 +#### func GetDigitValue(num int64, digit int) int64 > 接收一个整数 num 和一个表示目标位数的整数 digit 作为输入,并返 > 回数字 num 在指定位数上的数值。我们使用 math.Abs() 函数获取 num 的绝对值,并通 > 过除以10的操作将 num 移动到目标位数上。然后,通过取余运算得到位数上的数值 *** -#### func JoinNumbers(num1 V, n ...V) V +#### func JoinNumbers(num1 V, n ...V) V > 将一组数字连接起来 *** -#### func IsOdd(n V) bool +#### func IsOdd(n V) bool > 返回 n 是否为奇数 *** -#### func IsEven(n V) bool +#### func IsEven(n V) bool > 返回 n 是否为偶数 *** -#### func MakeLastDigitsZero(num T, digits int) T +#### func MakeLastDigitsZero(num T, digits int) T > 返回一个新的数,其中 num 的最后 digits 位数被设为零。 > - 函数首先创建一个 10 的 digits 次方的遮罩,然后通过整除和乘以这个遮罩来使 num 的最后 digits 位归零。 diff --git a/utils/memory/README.md b/utils/memory/README.md index 4d1c180..2525618 100644 --- a/utils/memory/README.md +++ b/utils/memory/README.md @@ -38,7 +38,7 @@ > 运行持久化缓存程序 *** -#### func BindPersistCacheProgram(name string, handler OutputParamHandlerFunc, option ...*Option) func () +#### func BindPersistCacheProgram(name string, handler OutputParamHandlerFunc, option ...*Option) func () > 绑定持久化缓存程序 > - name 持久化缓存程序名称 @@ -52,7 +52,7 @@ > - 所有持久化程序绑定完成后,应该主动调用 Run 函数运行 *** -#### func BindAction(name string, handler Func) Func +#### func BindAction(name string, handler Func) Func > 绑定需要缓存的操作函数 > - name 缓存操作名称 @@ -92,7 +92,7 @@ func TestBindAction(t *testing.T) { *** -#### func NewOption() *Option +#### func NewOption() *Option *** diff --git a/utils/moving/README.md b/utils/moving/README.md index e243217..8cefd3d 100644 --- a/utils/moving/README.md +++ b/utils/moving/README.md @@ -37,7 +37,7 @@ *** ## 详情信息 -#### func NewTwoDimensional(options ...TwoDimensionalOption[EID, PosType]) *TwoDimensional[EID, PosType] +#### func NewTwoDimensional(options ...TwoDimensionalOption[EID, PosType]) *TwoDimensional[EID, PosType] > 创建一个用于2D对象移动的实例(TwoDimensional) @@ -74,24 +74,24 @@ func TestNewTwoDimensional(t *testing.T) { *** -#### func WithTwoDimensionalTimeUnit(duration time.Duration) TwoDimensionalOption[EID, PosType] +#### func WithTwoDimensionalTimeUnit(duration time.Duration) TwoDimensionalOption[EID, PosType] > 通过特定时间单位创建 > - 默认单位为1毫秒,最小单位也为1毫秒 *** -#### func WithTwoDimensionalIdleWaitTime(duration time.Duration) TwoDimensionalOption[EID, PosType] +#### func WithTwoDimensionalIdleWaitTime(duration time.Duration) TwoDimensionalOption[EID, PosType] > 通过特定的空闲等待时间创建 > - 默认情况下在没有新的移动计划时将限制 100毫秒 + 移动间隔事件(默认100毫秒) *** -#### func WithTwoDimensionalInterval(duration time.Duration) TwoDimensionalOption[EID, PosType] +#### func WithTwoDimensionalInterval(duration time.Duration) TwoDimensionalOption[EID, PosType] > 通过特定的移动间隔时间创建 *** -#### func NewEntity(guid int64, speed float64) *MoveEntity +#### func NewEntity(guid int64, speed float64) *MoveEntity *** diff --git a/utils/offset/README.md b/utils/offset/README.md index 3c35959..4dd1b32 100644 --- a/utils/offset/README.md +++ b/utils/offset/README.md @@ -34,7 +34,7 @@ *** ## 详情信息 -#### func NewTime(offset time.Duration) *Time +#### func NewTime(offset time.Duration) *Time > 新建一个包含偏移的时间 @@ -44,17 +44,17 @@ > 设置全局偏移时间 *** -#### func GetGlobal() *Time +#### func GetGlobal() *Time > 获取全局偏移时间 *** -#### func Now() time.Time +#### func Now() time.Time > 获取当前时间偏移后的时间 *** -#### func Since(t time.Time) time.Duration +#### func Since(t time.Time) time.Duration > 获取当前时间偏移后的时间自从 t 以来经过的时间 diff --git a/utils/random/README.md b/utils/random/README.md index e607042..4747b7f 100644 --- a/utils/random/README.md +++ b/utils/random/README.md @@ -52,69 +52,69 @@ *** ## 详情信息 -#### func Dice() int +#### func Dice() int > 掷骰子 > - 常规掷骰子将返回 1-6 的随机数 *** -#### func DiceN(n int) int +#### func DiceN(n int) int > 掷骰子 > - 与 Dice 不同的是,将返回 1-N 的随机数 *** -#### func NetIP() net.IP +#### func NetIP() net.IP > 返回一个随机的IP地址 *** -#### func Port() int +#### func Port() int > 返回一个随机的端口号 *** -#### func IPv4() string +#### func IPv4() string > 返回一个随机产生的IPv4地址。 *** -#### func IPv4Port() string +#### func IPv4Port() string > 返回一个随机产生的IPv4地址和端口。 *** -#### func Int64(min int64, max int64) int64 +#### func Int64(min int64, max int64) int64 > 返回一个介于min和max之间的int64类型的随机数。 *** -#### func Int(min int, max int) int +#### func Int(min int, max int) int > 返回一个介于min和max之间的的int类型的随机数。 *** -#### func Duration(min int64, max int64) time.Duration +#### func Duration(min int64, max int64) time.Duration > 返回一个介于min和max之间的的Duration类型的随机数。 *** -#### func Float64() float64 +#### func Float64() float64 > 返回一个0~1的浮点数 *** -#### func Float32() float32 +#### func Float32() float32 > 返回一个0~1的浮点数 *** -#### func IntN(n int) int +#### func IntN(n int) int > 返回一个0~n的整数 *** -#### func Bool() bool +#### func Bool() bool > 返回一个随机的布尔值 @@ -153,13 +153,13 @@ func TestProbabilitySlice(t *testing.T) { > - 当总概率小于 1 将会发生未命中的情况 *** -#### func Probability(p int, full ...int) bool +#### func Probability(p int, full ...int) bool > 输入一个概率,返回是否命中 > - 当 full 不为空时,将以 full 为基数,p 为分子,计算命中概率 *** -#### func ProbabilityChooseOne(ps ...int) int +#### func ProbabilityChooseOne(ps ...int) int > 输入一组概率,返回命中的索引 @@ -168,39 +168,39 @@ func TestProbabilitySlice(t *testing.T) { *** -#### func ChineseName() string +#### func ChineseName() string > 返回一个随机组成的中文姓名。 *** -#### func EnglishName() string +#### func EnglishName() string > 返回一个随机组成的英文姓名。 *** -#### func Name() string +#### func Name() string > 返回一个随机组成的中文或英文姓名 > - 以1/2的概率决定生产的是中文还是英文姓名。 *** -#### func NumberString(min int, max int) string +#### func NumberString(min int, max int) string > 返回一个介于min和max之间的string类型的随机数。 *** -#### func NumberStringRepair(min int, max int) string +#### func NumberStringRepair(min int, max int) string > 返回一个介于min和max之间的string类型的随机数 > - 通过Int64生成一个随机数,当结果的字符串长度小于max的字符串长度的情况下,使用0在开头补齐。 *** -#### func HostName() string +#### func HostName() string > 返回一个随机产生的hostname。 *** -#### func WeightSlice(getWeightHandle func (data T) int64, data ...T) T +#### func WeightSlice(getWeightHandle func (data T) int64, data ...T) T > 按权重随机从切片中产生一个数据并返回 @@ -210,7 +210,7 @@ func TestProbabilitySlice(t *testing.T) { > 按权重随机从切片中产生一个数据并返回数据和对应索引 *** -#### func WeightMap(getWeightHandle func (data T) int64, data map[K]T) T +#### func WeightMap(getWeightHandle func (data T) int64, data map[K]T) T > 按权重随机从map中产生一个数据并返回 diff --git a/utils/reflects/README.md b/utils/reflects/README.md index bf685e0..950e693 100644 --- a/utils/reflects/README.md +++ b/utils/reflects/README.md @@ -52,7 +52,7 @@ > 包装函数,后置函数执行后 *** -#### func GetPtrUnExportFiled(s reflect.Value, filedIndex int) reflect.Value +#### func GetPtrUnExportFiled(s reflect.Value, filedIndex int) reflect.Value > 获取指针类型的未导出字段 @@ -62,12 +62,12 @@ > 设置指针类型的未导出字段 *** -#### func Copy(s reflect.Value) reflect.Value +#### func Copy(s reflect.Value) reflect.Value > 拷贝 *** -#### func GetPointer(src T) reflect.Value +#### func GetPointer(src T) reflect.Value > 获取指针 diff --git a/utils/runtimes/README.md b/utils/runtimes/README.md index 63c3494..b716fdb 100644 --- a/utils/runtimes/README.md +++ b/utils/runtimes/README.md @@ -29,27 +29,27 @@ *** ## 详情信息 -#### func GetWorkingDir() string +#### func GetWorkingDir() string > 获取工作目录绝对路径 *** -#### func GetTempDir() string +#### func GetTempDir() string > 获取系统临时目录 *** -#### func GetExecutablePathByBuild() string +#### func GetExecutablePathByBuild() string > 获取当前执行文件绝对路径(go build) *** -#### func GetExecutablePathByCaller() string +#### func GetExecutablePathByCaller() string > 获取当前执行文件绝对路径(go run) *** -#### func CurrentRunningFuncName(skip ...int) string +#### func CurrentRunningFuncName(skip ...int) string > 获取正在运行的函数名 diff --git a/utils/sole/README.md b/utils/sole/README.md index b02da32..786c068 100644 --- a/utils/sole/README.md +++ b/utils/sole/README.md @@ -55,7 +55,7 @@ > 解除注销特定命名空间的唯一标识符 *** -#### func Get() int64 +#### func Get() int64 > 获取全局唯一标识符 @@ -65,7 +65,7 @@ > 重置全局唯一标识符 *** -#### func GetWith(name any) int64 +#### func GetWith(name any) int64 > 获取特定命名空间的唯一标识符 @@ -75,17 +75,17 @@ > 重置特定命名空间的唯一标识符 *** -#### func NewOnce() *Once[V] +#### func NewOnce() *Once[V] > 创建一个用于数据取值去重的结构实例 *** -#### func SonyflakeIDE() int64, error +#### func SonyflakeIDE() (int64, error) > 获取一个雪花id *** -#### func SonyflakeID() int64 +#### func SonyflakeID() int64 > 获取一个雪花id @@ -95,32 +95,32 @@ > 配置雪花id生成策略 *** -#### func AutoIncrementUint32() uint32 +#### func AutoIncrementUint32() uint32 > 获取一个自增的 uint32 值 *** -#### func AutoIncrementUint64() uint64 +#### func AutoIncrementUint64() uint64 > 获取一个自增的 uint64 值 *** -#### func AutoIncrementInt32() int32 +#### func AutoIncrementInt32() int32 > 获取一个自增的 int32 值 *** -#### func AutoIncrementInt64() int64 +#### func AutoIncrementInt64() int64 > 获取一个自增的 int64 值 *** -#### func AutoIncrementInt() int +#### func AutoIncrementInt() int > 获取一个自增的 int 值 *** -#### func AutoIncrementString() string +#### func AutoIncrementString() string > 获取一个自增的字符串 diff --git a/utils/sorts/README.md b/utils/sorts/README.md index 6375347..bc1ef79 100644 --- a/utils/sorts/README.md +++ b/utils/sorts/README.md @@ -25,7 +25,7 @@ *** ## 详情信息 -#### func Topological(slice S, queryIndexHandler func (item V) Index, queryDependsHandler func (item V) []Index) S, error +#### func Topological(slice S, queryIndexHandler func (item V) Index, queryDependsHandler func (item V) []Index) (S, error) > 拓扑排序是一种对有向图进行排序的算法,它可以用来解决一些依赖关系的问题,比如计算字段的依赖关系。拓扑排序会将存在依赖关系的元素进行排序,使得依赖关系的元素总是排在被依赖的元素之前。 > - slice: 需要排序的切片 diff --git a/utils/str/README.md b/utils/str/README.md index 04e35d0..a0d020a 100644 --- a/utils/str/README.md +++ b/utils/str/README.md @@ -46,7 +46,7 @@ *** ## 详情信息 -#### func RangeLine(eachString string, eachFunc func (index int, line string) error) error +#### func RangeLine(eachString string, eachFunc func (index int, line string) error) error > 对传入的eachString进行按行切片后再进行遍历 > - 该函数会预先对“\r\n”进行处理替换为“\n”。 @@ -54,72 +54,72 @@ > - index表示了当前行的行号(由0开始),line表示了当前行的内容。 *** -#### func SplitTrimSpace(str string, sep string) []string +#### func SplitTrimSpace(str string, sep string) []string > 按照空格分割字符串并去除空格 *** -#### func FirstUpper(str string) string +#### func FirstUpper(str string) string > 首字母大写 *** -#### func FirstLower(str string) string +#### func FirstLower(str string) string > 首字母小写 *** -#### func FirstUpperBytes(str []byte) []byte +#### func FirstUpperBytes(str []byte) []byte > 首字母大写 *** -#### func FirstLowerBytes(str []byte) []byte +#### func FirstLowerBytes(str []byte) []byte > 首字母小写 *** -#### func IsEmpty(str string) bool +#### func IsEmpty(str string) bool > 判断字符串是否为空 *** -#### func IsEmptyBytes(str []byte) bool +#### func IsEmptyBytes(str []byte) bool > 判断字符串是否为空 *** -#### func IsNotEmpty(str string) bool +#### func IsNotEmpty(str string) bool > 判断字符串是否不为空 *** -#### func IsNotEmptyBytes(str []byte) bool +#### func IsNotEmptyBytes(str []byte) bool > 判断字符串是否不为空 *** -#### func SnakeString(str string) string +#### func SnakeString(str string) string > 蛇形字符串 *** -#### func SnakeStringBytes(str []byte) []byte +#### func SnakeStringBytes(str []byte) []byte > 蛇形字符串 *** -#### func CamelString(str string) string +#### func CamelString(str string) string > 驼峰字符串 *** -#### func CamelStringBytes(str []byte) []byte +#### func CamelStringBytes(str []byte) []byte > 驼峰字符串 *** -#### func SortJoin(delimiter string, s ...string) string +#### func SortJoin(delimiter string, s ...string) string > 将多个字符串排序后拼接 @@ -130,19 +130,19 @@ > - 隐藏身份证、邮箱、手机号等敏感信息用*号替代 *** -#### func ThousandsSeparator(str string) string +#### func ThousandsSeparator(str string) string > 返回将str进行千位分隔符处理后的字符串。 *** -#### func KV(str string, tag ...string) string, string +#### func KV(str string, tag ...string) (string, string) > 返回str经过转换后形成的key、value > - 这里tag表示使用什么字符串来区分key和value的分隔符。 > - 默认情况即不传入tag的情况下分隔符为“=”。 *** -#### func FormatSpeedyInt(numberStr string) int, error +#### func FormatSpeedyInt(numberStr string) (int, error) > 返回numberStr经过格式化后去除空格和“,”分隔符的结果 > - 当字符串为“123,456,789”的时候,返回结果为“123456789”。 @@ -150,7 +150,7 @@ > - 当字符串为“1 23, 45 6, 789”的时候,返回结果为“123456789”。 *** -#### func FormatSpeedyInt64(numberStr string) int64, error +#### func FormatSpeedyInt64(numberStr string) (int64, error) > 返回numberStr经过格式化后去除空格和“,”分隔符的结果 > - 当字符串为“123,456,789”的时候,返回结果为“123456789”。 @@ -158,7 +158,7 @@ > - 当字符串为“1 23, 45 6, 789”的时候,返回结果为“123456789”。 *** -#### func FormatSpeedyFloat32(numberStr string) float64, error +#### func FormatSpeedyFloat32(numberStr string) (float64, error) > 返回numberStr经过格式化后去除空格和“,”分隔符的结果 > - 当字符串为“123,456,789.123”的时候,返回结果为“123456789.123”。 @@ -166,7 +166,7 @@ > - 当字符串为“1 23, 45 6, 789.123”的时候,返回结果为“123456789.123”。 *** -#### func FormatSpeedyFloat64(numberStr string) float64, error +#### func FormatSpeedyFloat64(numberStr string) (float64, error) > 返回numberStr经过格式化后去除空格和“,”分隔符的结果 > - 当字符串为“123,456,789.123”的时候,返回结果为“123456789.123”。 diff --git a/utils/super/README.md b/utils/super/README.md index b3561fb..a3feb3f 100644 --- a/utils/super/README.md +++ b/utils/super/README.md @@ -104,12 +104,12 @@ *** ## 详情信息 -#### func NewBitSet(bits ...Bit) *BitSet[Bit] +#### func NewBitSet(bits ...Bit) *BitSet[Bit] > 通过指定的 Bit 位创建一个 BitSet *** -#### func TryWriteChannel(ch chan T, data T) bool +#### func TryWriteChannel(ch chan T, data T) bool > 尝试写入 channel,如果 channel 无法写入则忽略,返回是否写入成功 > - 无法写入的情况包括:channel 已满、channel 已关闭 @@ -121,18 +121,18 @@ > - 无法写入的情况包括:channel 已满、channel 已关闭 *** -#### func RegError(code int, message string) error +#### func RegError(code int, message string) error > 通过错误码注册错误,返回错误的引用 *** -#### func RegErrorRef(code int, message string, ref error) error +#### func RegErrorRef(code int, message string, ref error) error > 通过错误码注册错误,返回错误的引用 > - 引用将会被重定向到注册的错误信息 *** -#### func GetError(err error) int, error +#### func GetError(err error) (int, error) > 通过错误引用获取错误码和真实错误信息,如果错误不存在则返回 0,如果错误引用不存在则返回原本的错误 @@ -155,7 +155,7 @@ func TestGetError(t *testing.T) { *** -#### func RecoverTransform(a any) error +#### func RecoverTransform(a any) error > recover 错误转换 @@ -179,7 +179,7 @@ func ExampleRecoverTransform() { > 执行 f 函数,如果 f 为 nil,则不执行 *** -#### func HandleErr(f func () error) error +#### func HandleErr(f func () error) error > 执行 f 函数,如果 f 为 nil,则不执行 @@ -194,43 +194,43 @@ func ExampleRecoverTransform() { > go 代码格式化 *** -#### func If(expression bool, t T, f T) T +#### func If(expression bool, t T, f T) T *** -#### func MarshalJSON(v interface {}) []byte +#### func MarshalJSON(v interface {}) []byte > 将对象转换为 json > - 当转换失败时,将返回 json 格式的空对象 *** -#### func MarshalJSONE(v interface {}) []byte, error +#### func MarshalJSONE(v interface {}) ([]byte, error) > 将对象转换为 json > - 当转换失败时,将返回错误信息 *** -#### func UnmarshalJSON(data []byte, v interface {}) error +#### func UnmarshalJSON(data []byte, v interface {}) error > 将 json 转换为对象 *** -#### func MarshalIndentJSON(v interface {}, prefix string, indent string) []byte +#### func MarshalIndentJSON(v interface {}, prefix string, indent string) []byte > 将对象转换为 json *** -#### func MarshalToTargetWithJSON(src interface {}, dest interface {}) error +#### func MarshalToTargetWithJSON(src interface {}, dest interface {}) error > 将对象转换为目标对象 *** -#### func StartLossCounter() *LossCounter +#### func StartLossCounter() *LossCounter > 开始损耗计数 *** -#### func Match(value Value) *Matcher[Value, Result] +#### func Match(value Value) *Matcher[Value, Result] > 匹配 @@ -255,12 +255,12 @@ func TestMatch(t *testing.T) { *** -#### func IsNumber(v any) bool +#### func IsNumber(v any) bool > 判断是否为数字 *** -#### func NumberToRome(num int) string +#### func NumberToRome(num int) string > 将数字转换为罗马数字 @@ -290,167 +290,167 @@ func TestNumberToRome(t *testing.T) { *** -#### func StringToInt(value string) int +#### func StringToInt(value string) int > 字符串转换为整数 *** -#### func StringToFloat64(value string) float64 +#### func StringToFloat64(value string) float64 > 字符串转换为 float64 *** -#### func StringToBool(value string) bool +#### func StringToBool(value string) bool > 字符串转换为 bool *** -#### func StringToUint64(value string) uint64 +#### func StringToUint64(value string) uint64 > 字符串转换为 uint64 *** -#### func StringToUint(value string) uint +#### func StringToUint(value string) uint > 字符串转换为 uint *** -#### func StringToFloat32(value string) float32 +#### func StringToFloat32(value string) float32 > 字符串转换为 float32 *** -#### func StringToInt64(value string) int64 +#### func StringToInt64(value string) int64 > 字符串转换为 int64 *** -#### func StringToUint32(value string) uint32 +#### func StringToUint32(value string) uint32 > 字符串转换为 uint32 *** -#### func StringToInt32(value string) int32 +#### func StringToInt32(value string) int32 > 字符串转换为 int32 *** -#### func StringToUint16(value string) uint16 +#### func StringToUint16(value string) uint16 > 字符串转换为 uint16 *** -#### func StringToInt16(value string) int16 +#### func StringToInt16(value string) int16 > 字符串转换为 int16 *** -#### func StringToUint8(value string) uint8 +#### func StringToUint8(value string) uint8 > 字符串转换为 uint8 *** -#### func StringToInt8(value string) int8 +#### func StringToInt8(value string) int8 > 字符串转换为 int8 *** -#### func StringToByte(value string) byte +#### func StringToByte(value string) byte > 字符串转换为 byte *** -#### func StringToRune(value string) rune +#### func StringToRune(value string) rune > 字符串转换为 rune *** -#### func IntToString(value int) string +#### func IntToString(value int) string > 整数转换为字符串 *** -#### func Float64ToString(value float64) string +#### func Float64ToString(value float64) string > float64 转换为字符串 *** -#### func BoolToString(value bool) string +#### func BoolToString(value bool) string > bool 转换为字符串 *** -#### func Uint64ToString(value uint64) string +#### func Uint64ToString(value uint64) string > uint64 转换为字符串 *** -#### func UintToString(value uint) string +#### func UintToString(value uint) string > uint 转换为字符串 *** -#### func Float32ToString(value float32) string +#### func Float32ToString(value float32) string > float32 转换为字符串 *** -#### func Int64ToString(value int64) string +#### func Int64ToString(value int64) string > int64 转换为字符串 *** -#### func Uint32ToString(value uint32) string +#### func Uint32ToString(value uint32) string > uint32 转换为字符串 *** -#### func Int32ToString(value int32) string +#### func Int32ToString(value int32) string > int32 转换为字符串 *** -#### func Uint16ToString(value uint16) string +#### func Uint16ToString(value uint16) string > uint16 转换为字符串 *** -#### func Int16ToString(value int16) string +#### func Int16ToString(value int16) string > int16 转换为字符串 *** -#### func Uint8ToString(value uint8) string +#### func Uint8ToString(value uint8) string > uint8 转换为字符串 *** -#### func Int8ToString(value int8) string +#### func Int8ToString(value int8) string > int8 转换为字符串 *** -#### func ByteToString(value byte) string +#### func ByteToString(value byte) string > byte 转换为字符串 *** -#### func RuneToString(value rune) string +#### func RuneToString(value rune) string > rune 转换为字符串 *** -#### func StringToSlice(value string) []string +#### func StringToSlice(value string) []string > 字符串转换为切片 *** -#### func SliceToString(value []string) string +#### func SliceToString(value []string) string > 切片转换为字符串 *** -#### func NewPermission() *Permission[Code, EntityID] +#### func NewPermission() *Permission[Code, EntityID] > 创建权限 @@ -488,19 +488,19 @@ func TestNewPermission(t *testing.T) { *** -#### func Retry(count int, interval time.Duration, f func () error) error +#### func Retry(count int, interval time.Duration, f func () error) error > 根据提供的 count 次数尝试执行 f 函数,如果 f 函数返回错误,则在 interval 后重试,直到成功或者达到 count 次数 *** -#### func RetryByRule(f func () error, rule func (count int) time.Duration) error +#### func RetryByRule(f func () error, rule func (count int) time.Duration) error > 根据提供的规则尝试执行 f 函数,如果 f 函数返回错误,则根据 rule 的返回值进行重试 > - rule 将包含一个入参,表示第几次重试,返回值表示下一次重试的时间间隔,当返回值为 0 时,表示不再重试 > - rule 的 count 将在 f 首次失败后变为 1,因此 rule 的入参将从 1 开始 *** -#### func RetryByExponentialBackoff(f func () error, maxRetries int, baseDelay time.Duration, maxDelay time.Duration, multiplier float64, randomization float64, ignoreErrors ...error) error +#### func RetryByExponentialBackoff(f func () error, maxRetries int, baseDelay time.Duration, maxDelay time.Duration, multiplier float64, randomization float64, ignoreErrors ...error) error > 根据指数退避算法尝试执行 f 函数 > - maxRetries:最大重试次数 @@ -511,7 +511,7 @@ func TestNewPermission(t *testing.T) { > - ignoreErrors:忽略的错误,当 f 返回的错误在 ignoreErrors 中时,将不会进行重试 *** -#### func ConditionalRetryByExponentialBackoff(f func () error, cond func () bool, maxRetries int, baseDelay time.Duration, maxDelay time.Duration, multiplier float64, randomization float64, ignoreErrors ...error) error +#### func ConditionalRetryByExponentialBackoff(f func () error, cond func () bool, maxRetries int, baseDelay time.Duration, maxDelay time.Duration, multiplier float64, randomization float64, ignoreErrors ...error) error > 该函数与 RetryByExponentialBackoff 类似,但是可以被中断 > - cond 为中断条件,当 cond 返回 false 时,将会中断重试 @@ -532,37 +532,37 @@ func TestNewPermission(t *testing.T) { > 根据提供的 interval 时间间隔尝试执行 f 函数,如果 f 函数返回错误,则在 interval 后重试,直到成功 *** -#### func NewStackGo() *StackGo +#### func NewStackGo() *StackGo > 返回一个用于获取上一个协程调用的堆栈信息的收集器 *** -#### func LaunchTime() time.Time +#### func LaunchTime() time.Time > 获取程序启动时间 *** -#### func Hostname() string +#### func Hostname() string > 获取主机名 *** -#### func PID() int +#### func PID() int > 获取进程 PID *** -#### func StringToBytes(s string) []byte +#### func StringToBytes(s string) []byte > 以零拷贝的方式将字符串转换为字节切片 *** -#### func BytesToString(b []byte) string +#### func BytesToString(b []byte) string > 以零拷贝的方式将字节切片转换为字符串 *** -#### func Convert(src A) B +#### func Convert(src A) B > 以零拷贝的方式将一个对象转换为另一个对象 > - 两个对象字段必须完全一致 @@ -591,7 +591,7 @@ func TestConvert(t *testing.T) { *** -#### func Verify(handle func ( V)) *VerifyHandle[V] +#### func Verify(handle func ( V)) *VerifyHandle[V] > 对特定表达式进行校验,当表达式不成立时,将执行 handle @@ -618,7 +618,7 @@ func ExampleVerify() { ``` *** -#### func OldVersion(version1 string, version2 string) bool +#### func OldVersion(version1 string, version2 string) bool > 检查 version2 对于 version1 来说是不是旧版本 @@ -677,7 +677,7 @@ func BenchmarkOldVersion(b *testing.B) { *** -#### func CompareVersion(version1 string, version2 string) int +#### func CompareVersion(version1 string, version2 string) int > 返回一个整数,用于表示两个版本号的比较结果: > - 如果 version1 大于 version2,它将返回 1 @@ -901,7 +901,7 @@ func TestBitSet_Shrink(t *testing.T) { #### func (*BitSet) String() string > 返回当前 BitSet 的字符串表示 *** -#### func (*BitSet) MarshalJSON() []byte, error +#### func (*BitSet) MarshalJSON() ( []byte, error) > 实现 json.Marshaler 接口 *** #### func (*BitSet) UnmarshalJSON(data []byte) error diff --git a/utils/timer/README.md b/utils/timer/README.md index 63d2f22..9200c3f 100644 --- a/utils/timer/README.md +++ b/utils/timer/README.md @@ -66,17 +66,17 @@ > 偏移时间新的一天事件 *** -#### func WithCaller(handle func (name string, caller func ())) Option +#### func WithCaller(handle func (name string, caller func ())) Option > 通过其他的 handle 执行 Caller *** -#### func WithMark(mark string) Option +#### func WithMark(mark string) Option > 通过特定的标记创建定时器 *** -#### func NewPool(tickerPoolSize int) *Pool +#### func NewPool(tickerPoolSize int) *Pool > 创建一个定时器池,当 tickerPoolSize 小于等于 0 时,将会引发 panic,可指定为 DefaultTickerPoolSize @@ -87,7 +87,7 @@ > - 默认值为 DefaultTickerPoolSize,当定时器池中的定时器不足时,会自动创建新的定时器,当定时器释放时,会将多余的定时器进行释放,否则将放入定时器池中 *** -#### func GetTicker(size int, options ...Option) *Ticker +#### func GetTicker(size int, options ...Option) *Ticker > 获取标准池中的一个定时器 diff --git a/utils/times/README.md b/utils/times/README.md index ff82c67..66dbdc1 100644 --- a/utils/times/README.md +++ b/utils/times/README.md @@ -78,12 +78,12 @@ *** ## 详情信息 -#### func CalcNextSec(sec int) int +#### func CalcNextSec(sec int) int > 计算下一个N秒在多少秒之后 *** -#### func CalcNextSecWithTime(t time.Time, sec int) int +#### func CalcNextSecWithTime(t time.Time, sec int) int > 计算下一个N秒在多少秒之后 @@ -98,7 +98,7 @@ func ExampleCalcNextSecWithTime() { ``` *** -#### func CalcNextTimeWithRefer(now time.Time, refer time.Duration) time.Time +#### func CalcNextTimeWithRefer(now time.Time, refer time.Duration) time.Time > 根据参考时间计算下一个整点时间 > - 假设当 now 为 14:15:16 , 参考时间为 10 分钟, 则返回 14:20:00 @@ -112,69 +112,69 @@ func ExampleCalcNextSecWithTime() { > 针对 IntervalFormat 函数设置格式化内容 *** -#### func IntervalFormat(time1 time.Time, time2 time.Time) string +#### func IntervalFormat(time1 time.Time, time2 time.Time) string > 返回指定时间戳之间的间隔 > - 使用传入的时间进行计算换算,将结果体现为几年前、几天前、几小时前、几分钟前、几秒前。 *** -#### func GetMonthDays(t time.Time) int +#### func GetMonthDays(t time.Time) int > 获取一个时间当月共有多少天 *** -#### func WeekDay(t time.Time) int +#### func WeekDay(t time.Time) int > 获取一个时间是星期几 > - 1 ~ 7 *** -#### func GetNextDayInterval(t time.Time) time.Duration +#### func GetNextDayInterval(t time.Time) time.Duration > 获取一个时间到下一天间隔多少秒 *** -#### func GetToday(t time.Time) time.Time +#### func GetToday(t time.Time) time.Time > 获取一个时间的今天 *** -#### func GetSecond(d time.Duration) int +#### func GetSecond(d time.Duration) int > 获取共有多少秒 *** -#### func IsSameDay(t1 time.Time, t2 time.Time) bool +#### func IsSameDay(t1 time.Time, t2 time.Time) bool > 两个时间是否是同一天 *** -#### func IsSameHour(t1 time.Time, t2 time.Time) bool +#### func IsSameHour(t1 time.Time, t2 time.Time) bool > 两个时间是否是同一小时 *** -#### func GetMondayZero(t time.Time) time.Time +#### func GetMondayZero(t time.Time) time.Time > 获取本周一零点 *** -#### func Date(year int, month time.Month, day int) time.Time +#### func Date(year int, month time.Month, day int) time.Time > 返回一个特定日期的时间 *** -#### func DateWithHMS(year int, month time.Month, day int, hour int, min int, sec int) time.Time +#### func DateWithHMS(year int, month time.Month, day int, hour int, min int, sec int) time.Time > 返回一个精确到秒的时间 *** -#### func GetDeltaDay(t1 time.Time, t2 time.Time) int +#### func GetDeltaDay(t1 time.Time, t2 time.Time) int > 获取两个时间需要加减的天数 *** -#### func GetDeltaWeek(t1 time.Time, t2 time.Time) int +#### func GetDeltaWeek(t1 time.Time, t2 time.Time) int > 获取两个时间需要加减的周数 @@ -184,73 +184,73 @@ func ExampleCalcNextSecWithTime() { > 从时间字符串中获取时分秒 *** -#### func GetTimeFromString(timeStr string, layout string) time.Time +#### func GetTimeFromString(timeStr string, layout string) time.Time > 将时间字符串转化为时间 *** -#### func GetDayZero(t time.Time, day int) time.Time +#### func GetDayZero(t time.Time, day int) time.Time > 获取 t 增加 day 天后的零点时间 *** -#### func GetYesterday(t time.Time) time.Time +#### func GetYesterday(t time.Time) time.Time > 获取昨天 *** -#### func GetDayLast(t time.Time) time.Time +#### func GetDayLast(t time.Time) time.Time > 获取某天的最后一刻 > - 最后一刻即 23:59:59 *** -#### func GetYesterdayLast(t time.Time) time.Time +#### func GetYesterdayLast(t time.Time) time.Time > 获取昨天最后一刻 *** -#### func GetMinuteStart(t time.Time) time.Time +#### func GetMinuteStart(t time.Time) time.Time > 获取一个时间的 0 秒 *** -#### func GetMinuteEnd(t time.Time) time.Time +#### func GetMinuteEnd(t time.Time) time.Time > 获取一个时间的 59 秒 *** -#### func GetHourStart(t time.Time) time.Time +#### func GetHourStart(t time.Time) time.Time > 获取一个时间的 0 分 0 秒 *** -#### func GetHourEnd(t time.Time) time.Time +#### func GetHourEnd(t time.Time) time.Time > 获取一个时间的 59 分 59 秒 *** -#### func GetMonthStart(t time.Time) time.Time +#### func GetMonthStart(t time.Time) time.Time > 获取一个时间的月初 *** -#### func GetMonthEnd(t time.Time) time.Time +#### func GetMonthEnd(t time.Time) time.Time > 获取一个时间的月末 *** -#### func GetYearStart(t time.Time) time.Time +#### func GetYearStart(t time.Time) time.Time > 获取一个时间的年初 *** -#### func GetYearEnd(t time.Time) time.Time +#### func GetYearEnd(t time.Time) time.Time > 获取一个时间的年末 *** -#### func NewStateLine(zero State) *StateLine[State] +#### func NewStateLine(zero State) *StateLine[State] > 创建一个从左向右由早到晚的状态时间线 @@ -304,12 +304,12 @@ func TestSetGlobalTimeOffset(t *testing.T) { *** -#### func NowByNotOffset() time.Time +#### func NowByNotOffset() time.Time > 获取未偏移的当前时间 *** -#### func GetGlobalTimeOffset() time.Duration +#### func GetGlobalTimeOffset() time.Duration > 获取全局时间偏移量 @@ -319,13 +319,13 @@ func TestSetGlobalTimeOffset(t *testing.T) { > 重置全局时间偏移量 *** -#### func NewPeriod(start time.Time, end time.Time) Period +#### func NewPeriod(start time.Time, end time.Time) Period > 创建一个时间段 > - 如果 start 比 end 晚,则会自动交换两个时间 *** -#### func NewPeriodWindow(t time.Time, size time.Duration) Period +#### func NewPeriodWindow(t time.Time, size time.Duration) Period > 创建一个特定长度的时间窗口 @@ -349,52 +349,52 @@ func TestNewPeriodWindow(t *testing.T) { *** -#### func NewPeriodWindowWeek(t time.Time) Period +#### func NewPeriodWindowWeek(t time.Time) Period > 创建一周长度的时间窗口,从周一零点开始至周日 23:59:59 结束 *** -#### func NewPeriodWithTimeArray(times [2]time.Time) Period +#### func NewPeriodWithTimeArray(times [2]time.Time) Period > 创建一个时间段 *** -#### func NewPeriodWithDayZero(t time.Time, day int) Period +#### func NewPeriodWithDayZero(t time.Time, day int) Period > 创建一个时间段,从 t 开始,持续到 day 天后的 0 点 *** -#### func NewPeriodWithDay(t time.Time, day int) Period +#### func NewPeriodWithDay(t time.Time, day int) Period > 创建一个时间段,从 t 开始,持续 day 天 *** -#### func NewPeriodWithHour(t time.Time, hour int) Period +#### func NewPeriodWithHour(t time.Time, hour int) Period > 创建一个时间段,从 t 开始,持续 hour 小时 *** -#### func NewPeriodWithMinute(t time.Time, minute int) Period +#### func NewPeriodWithMinute(t time.Time, minute int) Period > 创建一个时间段,从 t 开始,持续 minute 分钟 *** -#### func NewPeriodWithSecond(t time.Time, second int) Period +#### func NewPeriodWithSecond(t time.Time, second int) Period > 创建一个时间段,从 t 开始,持续 second 秒 *** -#### func NewPeriodWithMillisecond(t time.Time, millisecond int) Period +#### func NewPeriodWithMillisecond(t time.Time, millisecond int) Period > 创建一个时间段,从 t 开始,持续 millisecond 毫秒 *** -#### func NewPeriodWithMicrosecond(t time.Time, microsecond int) Period +#### func NewPeriodWithMicrosecond(t time.Time, microsecond int) Period > 创建一个时间段,从 t 开始,持续 microsecond 微秒 *** -#### func NewPeriodWithNanosecond(t time.Time, nanosecond int) Period +#### func NewPeriodWithNanosecond(t time.Time, nanosecond int) Period > 创建一个时间段,从 t 开始,持续 nanosecond 纳秒 diff --git a/utils/xlsxtool/README.md b/utils/xlsxtool/README.md index 2fefedb..1dbcee7 100644 --- a/utils/xlsxtool/README.md +++ b/utils/xlsxtool/README.md @@ -25,7 +25,7 @@ *** ## 详情信息 -#### func GetSheetMatrix(sheet *xlsx.Sheet) *matrix.Matrix[*xlsx.Cell] +#### func GetSheetMatrix(sheet *xlsx.Sheet) *matrix.Matrix[*xlsx.Cell] > 将sheet转换为二维矩阵