docs: 优化 README.md 函数签名

This commit is contained in:
kercylan98 2024-01-15 10:37:51 +08:00
parent 8c80c4b00c
commit bd7a3fee6b
58 changed files with 608 additions and 596 deletions

View File

@ -75,28 +75,28 @@ activity 活动状态管理
> 加载所有活动实体数据
***
#### func LoadOrRefreshActivity(activityType Type, activityId ID, options ...*Options) error
#### func LoadOrRefreshActivity(activityType Type, activityId ID, options ...*Options) error
<span id="LoadOrRefreshActivity"></span>
> 加载或刷新活动
> - 通常在活动配置刷新时候将活动通过该方法注册或刷新
***
#### func DefineNoneDataActivity(activityType Type) NoneDataActivityController[Type, ID, *none, none, *none]
#### func DefineNoneDataActivity(activityType Type) NoneDataActivityController[Type, ID, *none, none, *none]
<span id="DefineNoneDataActivity"></span>
> 声明无数据的活动类型
***
#### func DefineGlobalDataActivity(activityType Type) GlobalDataActivityController[Type, ID, Data, none, *none]
#### func DefineGlobalDataActivity(activityType Type) GlobalDataActivityController[Type, ID, Data, none, *none]
<span id="DefineGlobalDataActivity"></span>
> 声明拥有全局数据的活动类型
***
#### func DefineEntityDataActivity(activityType Type) EntityDataActivityController[Type, ID, *none, EntityID, EntityData]
#### func DefineEntityDataActivity(activityType Type) EntityDataActivityController[Type, ID, *none, EntityID, EntityData]
<span id="DefineEntityDataActivity"></span>
> 声明拥有实体数据的活动类型
***
#### func DefineGlobalAndEntityDataActivity(activityType Type) GlobalAndEntityDataActivityController[Type, ID, Data, EntityID, EntityData]
#### func DefineGlobalAndEntityDataActivity(activityType Type) GlobalAndEntityDataActivityController[Type, ID, Data, EntityID, EntityData]
<span id="DefineGlobalAndEntityDataActivity"></span>
> 声明拥有全局数据和实体数据的活动类型
@ -161,7 +161,7 @@ activity 活动状态管理
> 新的一天事件
***
#### func NewOptions() *Options
#### func NewOptions() *Options
<span id="NewOptions"></span>
> 创建活动选项

View File

@ -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]
<span id="NewTurnBased"></span>
> 创建一个新的回合制
> - calcNextTurnDuration 将返回下一次行动时间间隔,适用于按照速度计算下一次行动时间间隔的情况。当返回 0 时,将使用默认的行动超时时间

View File

@ -34,7 +34,7 @@ space 游戏中常见的空间设计,例如房间、地图等
***
## 详情信息
#### func NewRoomManager() *RoomManager[EntityID, RoomID, Entity, Room]
#### func NewRoomManager() *RoomManager[EntityID, RoomID, Entity, Room]
<span id="NewRoomManager"></span>
> 创建房间管理器 RoomManager 的实例
@ -49,7 +49,7 @@ func ExampleNewRoomManager() {
```
***
#### func NewRoomControllerOptions() *RoomControllerOptions[EntityID, RoomID, Entity, Room]
#### func NewRoomControllerOptions() *RoomControllerOptions[EntityID, RoomID, Entity, Room]
<span id="NewRoomControllerOptions"></span>
> 创建房间控制器选项

View File

@ -45,7 +45,7 @@
***
## 详情信息
#### func Cond(k any, v any) Condition
#### func Cond(k any, v any) Condition
<span id="Cond"></span>
> 创建任务条件
@ -108,19 +108,19 @@ func TestCond(t *testing.T) {
> 触发特定任务类型的刷新任务条件事件
***
#### func WithType(taskType string) Option
#### func WithType(taskType string) Option
<span id="WithType"></span>
> 设置任务类型
***
#### func WithCondition(condition Condition) Option
#### func WithCondition(condition Condition) Option
<span id="WithCondition"></span>
> 设置任务完成条件,当满足条件时,任务状态为完成
> - 任务条件值需要变更时可通过 Task.AssignConditionValueAndRefresh 方法变更
> - 当多次设置该选项时,后面的设置会覆盖之前的设置
***
#### func WithCounter(counter int64, initCount ...int64) Option
#### func WithCounter(counter int64, initCount ...int64) Option
<span id="WithCounter"></span>
> 设置任务计数器,当计数器达到要求时,任务状态为完成
> - 一些场景下,任务计数器可能会溢出,此时可通过 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
<span id="WithOverflowCounter"></span>
> 设置可溢出的任务计数器,当计数器达到要求时,任务状态为完成
> - 当多次设置该选项时,后面的设置会覆盖之前的设置
> - 如果需要初始化计数器的值,可通过 initCount 参数设置
***
#### func WithDeadline(deadline time.Time) Option
#### func WithDeadline(deadline time.Time) Option
<span id="WithDeadline"></span>
> 设置任务截止时间,超过截至时间并且任务未完成时,任务状态为失败
***
#### func WithLimitedDuration(start time.Time, duration time.Duration) Option
#### func WithLimitedDuration(start time.Time, duration time.Duration) Option
<span id="WithLimitedDuration"></span>
> 设置任务限时,超过限时时间并且任务未完成时,任务状态为失败
***
#### func NewTask(options ...Option) *Task
#### func NewTask(options ...Option) *Task
<span id="NewTask"></span>
> 生成任务

View File

@ -32,7 +32,7 @@ notify 包含了对外部第三方通知的实现,如机器人消息等
***
## 详情信息
#### func NewManager(senders ...Sender) *Manager
#### func NewManager(senders ...Sender) *Manager
<span id="NewManager"></span>
> 通过指定的 Sender 创建一个通知管理器, senders 包中提供了一些内置的 Sender

View File

@ -45,12 +45,12 @@ notifies 包含了内置通知内容的实现
***
## 详情信息
#### func NewFeiShu(message FeiShuMessage) *FeiShu
#### func NewFeiShu(message FeiShuMessage) *FeiShu
<span id="NewFeiShu"></span>
> 创建飞书通知消息
***
#### func FeiShuMessageWithText(text string) FeiShuMessage
#### func FeiShuMessageWithText(text string) FeiShuMessage
<span id="FeiShuMessageWithText"></span>
> 飞书文本消息
> - 支持通过换行符进行消息换行
@ -68,24 +68,24 @@ notifies 包含了内置通知内容的实现
> - 请确保链接是合法的,否则会以原始内容发送消息。
***
#### func FeiShuMessageWithRichText(richText *FeiShuRichText) FeiShuMessage
#### func FeiShuMessageWithRichText(richText *FeiShuRichText) FeiShuMessage
<span id="FeiShuMessageWithRichText"></span>
> 飞书富文本消息
***
#### func FeiShuMessageWithImage(imageKey string) FeiShuMessage
#### func FeiShuMessageWithImage(imageKey string) FeiShuMessage
<span id="FeiShuMessageWithImage"></span>
> 飞书图片消息
> - imageKey 可通过上传图片接口获取
***
#### func FeiShuMessageWithInteractive(json string) FeiShuMessage
#### func FeiShuMessageWithInteractive(json string) FeiShuMessage
<span id="FeiShuMessageWithInteractive"></span>
> 飞书卡片消息
> - json 表示卡片的 json 数据或者消息模板的 json 数据
***
#### func FeiShuMessageWithShareChat(chatId string) FeiShuMessage
#### func FeiShuMessageWithShareChat(chatId string) FeiShuMessage
<span id="FeiShuMessageWithShareChat"></span>
> 飞书分享群名片
> - 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
<span id="FeiShuMessageWithShareUser"></span>
> 飞书分享个人名片
> - userId 表示用户的 OpenID 获取方式请参见了解更多:如何获取 Open ID
@ -101,7 +101,7 @@ notifies 包含了内置通知内容的实现
> 如何获取 Open IDhttps://open.feishu.cn/document/faq/trouble-shooting/how-to-obtain-openid
***
#### func FeiShuMessageWithAudio(fileKey string) FeiShuMessage
#### func FeiShuMessageWithAudio(fileKey string) FeiShuMessage
<span id="FeiShuMessageWithAudio"></span>
> 飞书语音消息
> - 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
<span id="FeiShuMessageWithMedia"></span>
> 飞书视频消息
> - 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
<span id="FeiShuMessageWithMediaAndCover"></span>
> 飞书带封面的视频消息
> - 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
<span id="FeiShuMessageWithFile"></span>
> 飞书文件消息
> - 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
<span id="FeiShuMessageWithSticker"></span>
> 飞书表情包消息
> - 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
<span id="NewFeiShuRichText"></span>
> 创建一个飞书富文本
@ -155,7 +155,7 @@ type FeiShu struct {
MsgType string
}
```
#### func (*FeiShu) Format() string, error
#### func (*FeiShu) Format() ( string, error)
> 格式化通知内容
***
### FeiShuMessage `STRUCT`

View File

@ -30,7 +30,7 @@ senders Package 包含了内置通知发送器的实现
***
## 详情信息
#### func NewFeiShu(webhook string) *FeiShu
#### func NewFeiShu(webhook string) *FeiShu
<span id="NewFeiShu"></span>
> 根据特定的 webhook 地址创建飞书发送器

View File

@ -69,12 +69,12 @@
***
## 详情信息
#### func NewExporter() *Exporter
#### func NewExporter() *Exporter
<span id="NewExporter"></span>
> 创建导出器
***
#### func GetFieldGolangType(field Field) string
#### func GetFieldGolangType(field Field) string
<span id="GetFieldGolangType"></span>
> 获取字段的 Golang 类型
@ -95,12 +95,12 @@ func TestGetFieldGolangType(t *testing.T) {
***
#### func GetFields() []Field
#### func GetFields() []Field
<span id="GetFields"></span>
> 获取所有内置支持的字段
***
#### func NewLoader(fields []Field) *Loader
#### func NewLoader(fields []Field) *Loader
<span id="NewLoader"></span>
> 创建加载器
> - 加载器被用于加载配置表的数据和结构信息
@ -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`

View File

@ -31,7 +31,7 @@
***
## 详情信息
#### func NewXlsx(sheet *xlsx.Sheet, exportType XlsxExportType) *Xlsx
#### func NewXlsx(sheet *xlsx.Sheet, exportType XlsxExportType) *Xlsx
<span id="NewXlsx"></span>
***

View File

@ -32,12 +32,12 @@
***
## 详情信息
#### func NewGolang(packageName string) *Golang
#### func NewGolang(packageName string) *Golang
<span id="NewGolang"></span>
> 创建一个 Golang 配置导出模板
***
#### func NewJSON() *JSON
#### func NewJSON() *JSON
<span id="NewJSON"></span>
***
@ -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)
***

View File

@ -80,7 +80,7 @@ server 提供了包含多种网络类型的服务器实现
***
## 详情信息
#### func NewBot(srv *Server, options ...BotOption) *Bot
#### func NewBot(srv *Server, options ...BotOption) *Bot
<span id="NewBot"></span>
> 创建一个机器人,目前仅支持 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
<span id="WithBotNetworkDelay"></span>
> 设置机器人网络延迟及波动范围
> - delay 延迟
> - fluctuation 波动范围
***
#### func WithBotWriter(construction func (bot *Bot) io.Writer) BotOption
#### func WithBotWriter(construction func (bot *Bot) io.Writer) BotOption
<span id="WithBotWriter"></span>
> 设置机器人写入器,默认为 os.Stdout
***
#### func DefaultWebsocketUpgrader() *websocket.Upgrader
#### func DefaultWebsocketUpgrader() *websocket.Upgrader
<span id="DefaultWebsocketUpgrader"></span>
***
#### func NewHttpHandleWrapper(srv *Server, packer ContextPacker[Context]) *Http[Context]
#### func NewHttpHandleWrapper(srv *Server, packer ContextPacker[Context]) *Http[Context]
<span id="NewHttpHandleWrapper"></span>
> 创建一个新的 http 处理程序包装器
> - 默认使用 server.HttpContext 作为上下文,如果需要依赖其作为新的上下文,可以通过 NewHttpContext 创建
***
#### func NewHttpContext(ctx *gin.Context) *HttpContext
#### func NewHttpContext(ctx *gin.Context) *HttpContext
<span id="NewHttpContext"></span>
> 基于 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]
<span id="NewGinWrapper"></span>
> 创建 gin 包装器,用于对 NewHttpWrapper 函数的替代
***
#### func HasMessageType(mt MessageType) bool
#### func HasMessageType(mt MessageType) bool
<span id="HasMessageType"></span>
> 检查是否存在指定的消息类型
***
#### func NewMultipleServer(serverHandle ...func () ((addr string, srv *Server))) *MultipleServer
#### func NewMultipleServer(serverHandle ...func () ((addr string, srv *Server))) *MultipleServer
<span id="NewMultipleServer"></span>
***
#### func GetNetworks() []Network
#### func GetNetworks() []Network
<span id="GetNetworks"></span>
> 获取所有支持的网络模式
***
#### func WithLowMessageDuration(duration time.Duration) Option
#### func WithLowMessageDuration(duration time.Duration) Option
<span id="WithLowMessageDuration"></span>
> 通过指定慢消息时长的方式创建服务器,当消息处理时间超过指定时长时,将会输出 WARN 类型的日志
> - 默认值为 DefaultLowMessageDuration
> - 当 duration <= 0 时,表示关闭慢消息检测
***
#### func WithAsyncLowMessageDuration(duration time.Duration) Option
#### func WithAsyncLowMessageDuration(duration time.Duration) Option
<span id="WithAsyncLowMessageDuration"></span>
> 通过指定异步消息的慢消息时长的方式创建服务器,当消息处理时间超过指定时长时,将会输出 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
<span id="WithWebsocketConnInitializer"></span>
> 通过 websocket 连接初始化的方式创建服务器,当 initializer 返回错误时,服务器将不会处理该连接的后续逻辑
> - 该选项仅在创建 NetworkWebsocket 服务器时有效
***
#### func WithWebsocketUpgrade(upgrader *websocket.Upgrader) Option
#### func WithWebsocketUpgrade(upgrader *websocket.Upgrader) Option
<span id="WithWebsocketUpgrade"></span>
> 通过指定 websocket.Upgrader 的方式创建服务器
> - 默认值为 DefaultWebsocketUpgrader
> - 该选项仅在创建 NetworkWebsocket 服务器时有效
***
#### func WithConnWriteBufferSize(size int) Option
#### func WithConnWriteBufferSize(size int) Option
<span id="WithConnWriteBufferSize"></span>
> 通过连接写入缓冲区大小的方式创建服务器
> - 默认值为 DefaultConnWriteBufferSize
> - 设置合适的缓冲区大小可以提高服务器性能,但是会占用更多的内存
***
#### func WithDispatcherBufferSize(size int) Option
#### func WithDispatcherBufferSize(size int) Option
<span id="WithDispatcherBufferSize"></span>
> 通过消息分发器缓冲区大小的方式创建服务器
> - 默认值为 DefaultDispatcherBufferSize
> - 设置合适的缓冲区大小可以提高服务器性能,但是会占用更多的内存
***
#### func WithMessageStatistics(duration time.Duration, limit int) Option
#### func WithMessageStatistics(duration time.Duration, limit int) Option
<span id="WithMessageStatistics"></span>
> 通过消息统计的方式创建服务器
> - 默认不开启,当 duration 和 limit 均大于 0 的时候,服务器将记录每 duration 期间的消息数量,并保留最多 limit 条
***
#### func WithPacketWarnSize(size int) Option
#### func WithPacketWarnSize(size int) Option
<span id="WithPacketWarnSize"></span>
> 通过数据包大小警告的方式创建服务器,当数据包大小超过指定大小时,将会输出 WARN 类型的日志
> - 默认值为 DefaultPacketWarnSize
> - 当 size <= 0 时,表示不设置警告
***
#### func WithLimitLife(t time.Duration) Option
#### func WithLimitLife(t time.Duration) Option
<span id="WithLimitLife"></span>
> 通过限制最大生命周期的方式创建服务器
> - 通常用于测试服务器,服务器将在到达最大生命周期时自动关闭
***
#### func WithWebsocketWriteCompression() Option
#### func WithWebsocketWriteCompression() Option
<span id="WithWebsocketWriteCompression"></span>
> 通过数据写入压缩的方式创建Websocket服务器
> - 默认不开启数据压缩
***
#### func WithWebsocketCompression(level int) Option
#### func WithWebsocketCompression(level int) Option
<span id="WithWebsocketCompression"></span>
> 通过数据压缩的方式创建Websocket服务器
> - 默认不开启数据压缩
***
#### func WithDeadlockDetect(t time.Duration) Option
#### func WithDeadlockDetect(t time.Duration) Option
<span id="WithDeadlockDetect"></span>
> 通过死锁、死循环、永久阻塞检测的方式创建服务器
> - 当检测到死锁、死循环、永久阻塞时,服务器将会生成 WARN 类型的日志,关键字为 "SuspectedDeadlock"
> - 默认不开启死锁检测
***
#### func WithDisableAsyncMessage() Option
#### func WithDisableAsyncMessage() Option
<span id="WithDisableAsyncMessage"></span>
> 通过禁用异步消息的方式创建服务器
***
#### func WithAsyncPoolSize(size int) Option
#### func WithAsyncPoolSize(size int) Option
<span id="WithAsyncPoolSize"></span>
> 通过指定异步消息池大小的方式创建服务器
> - 当通过 WithDisableAsyncMessage 禁用异步消息时,此选项无效
> - 默认值为 DefaultAsyncPoolSize
***
#### func WithWebsocketReadDeadline(t time.Duration) Option
#### func WithWebsocketReadDeadline(t time.Duration) Option
<span id="WithWebsocketReadDeadline"></span>
> 设置 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
<span id="WithTicker"></span>
> 通过定时器创建服务器,为服务器添加定时器功能
> - 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
<span id="WithTLS"></span>
> 通过安全传输层协议TLS创建服务器
> - 支持Http、Websocket
***
#### func WithGRPCServerOptions(options ...grpc.ServerOption) Option
#### func WithGRPCServerOptions(options ...grpc.ServerOption) Option
<span id="WithGRPCServerOptions"></span>
> 通过GRPC的可选项创建GRPC服务器
***
#### func WithWebsocketMessageType(messageTypes ...int) Option
#### func WithWebsocketMessageType(messageTypes ...int) Option
<span id="WithWebsocketMessageType"></span>
> 设置仅支持特定类型的Websocket消息
***
#### func WithPProf(pattern ...string) Option
#### func WithPProf(pattern ...string) Option
<span id="WithPProf"></span>
> 通过性能分析工具PProf创建服务器
***
#### func New(network Network, options ...Option) *Server
#### func New(network Network, options ...Option) *Server
<span id="New"></span>
> 根据特定网络类型创建一个服务器
@ -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

View File

@ -40,25 +40,25 @@
***
## 详情信息
#### func NewClient(core Core) *Client
#### func NewClient(core Core) *Client
<span id="NewClient"></span>
> 创建客户端
***
#### func CloneClient(client *Client) *Client
#### func CloneClient(client *Client) *Client
<span id="CloneClient"></span>
> 克隆客户端
***
#### func NewTCP(addr string) *Client
#### func NewTCP(addr string) *Client
<span id="NewTCP"></span>
***
#### func NewUnixDomainSocket(addr string) *Client
#### func NewUnixDomainSocket(addr string) *Client
<span id="NewUnixDomainSocket"></span>
***
#### func NewWebsocket(addr string) *Client
#### func NewWebsocket(addr string) *Client
<span id="NewWebsocket"></span>
> 创建 websocket 客户端

View File

@ -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
<span id="NewEndpoint"></span>
> 创建网关端点
***
#### func WithEndpointStateEvaluator(evaluator func (costUnixNano float64) float64) EndpointOption
#### func WithEndpointStateEvaluator(evaluator func (costUnixNano float64) float64) EndpointOption
<span id="WithEndpointStateEvaluator"></span>
> 设置端点健康值评估函数
***
#### func WithEndpointConnectionPoolSize(size int) EndpointOption
#### func WithEndpointConnectionPoolSize(size int) EndpointOption
<span id="WithEndpointConnectionPoolSize"></span>
> 设置端点连接池大小
> - 默认为 DefaultEndpointConnectionPoolSize
@ -63,25 +63,25 @@ gateway 是用于处理服务器消息的网关模块,适用于对客户端消
> - 在网关服务器中,多个客户端在发送消息到端点服务器时,会共用一个连接,适当的增大连接池大小可以提高网关服务器的承载能力
***
#### func WithEndpointReconnectInterval(interval time.Duration) EndpointOption
#### func WithEndpointReconnectInterval(interval time.Duration) EndpointOption
<span id="WithEndpointReconnectInterval"></span>
> 设置端点重连间隔
> - 默认为 DefaultEndpointReconnectInterval
> - 端点在连接失败后会在该间隔后重连,如果 <= 0 则不会重连
***
#### func NewGateway(srv *server.Server, scanner Scanner, options ...Option) *Gateway
#### func NewGateway(srv *server.Server, scanner Scanner, options ...Option) *Gateway
<span id="NewGateway"></span>
> 基于 server.Server 创建 Gateway 网关服务器
***
#### func WithEndpointSelector(selector EndpointSelector) Option
#### func WithEndpointSelector(selector EndpointSelector) Option
<span id="WithEndpointSelector"></span>
> 设置端点选择器
> - 默认情况下,网关会随机选择一个端点作为目标,如果需要自定义端点选择器,可以通过该选项设置
***
#### func MarshalGatewayOutPacket(addr string, packet []byte) []byte, error
#### func MarshalGatewayOutPacket(addr string, packet []byte) ([]byte, error)
<span id="MarshalGatewayOutPacket"></span>
> 将数据包转换为网关出网数据包
> - | 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)
<span id="MarshalGatewayInPacket"></span>
> 将数据包转换为网关入网数据包
> - | 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
***

View File

@ -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]
<span id="NewDispatcher"></span>
> 创建一个新的消息分发器 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]
<span id="NewManager"></span>
> 生成消息分发器管理器

View File

@ -37,7 +37,7 @@
***
## 详情信息
#### func NewLockstep(options ...Option[ClientID, Command]) *Lockstep[ClientID, Command]
#### func NewLockstep(options ...Option[ClientID, Command]) *Lockstep[ClientID, Command]
<span id="NewLockstep"></span>
> 创建一个锁步(帧)同步默认实现的组件(Lockstep)进行返回
@ -78,19 +78,19 @@ func TestNewLockstep(t *testing.T) {
***
#### func WithFrameLimit(frameLimit int64) Option[ClientID, Command]
#### func WithFrameLimit(frameLimit int64) Option[ClientID, Command]
<span id="WithFrameLimit"></span>
> 通过特定逻辑帧上限创建锁步(帧)同步组件
> - 当达到上限时将停止广播
***
#### func WithFrameRate(frameRate int64) Option[ClientID, Command]
#### func WithFrameRate(frameRate int64) Option[ClientID, Command]
<span id="WithFrameRate"></span>
> 通过特定逻辑帧率创建锁步(帧)同步组件
> - 默认情况下为 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]
<span id="WithSerialization"></span>
> 通过特定的序列化方式将每一帧的数据进行序列化
>
@ -102,7 +102,7 @@ func TestNewLockstep(t *testing.T) {
> }
***
#### func WithInitFrame(initFrame int64) Option[ClientID, Command]
#### func WithInitFrame(initFrame int64) Option[ClientID, Command]
<span id="WithInitFrame"></span>
> 通过特定的初始帧创建锁步(帧)同步组件
> - 默认情况下为 0即第一帧索引为 0

View File

@ -33,7 +33,7 @@
***
## 详情信息
#### func NewMultistage(options ...MultistageOption[HandleFunc]) *Multistage[HandleFunc]
#### func NewMultistage(options ...MultistageOption[HandleFunc]) *Multistage[HandleFunc]
<span id="NewMultistage"></span>
> 创建一个支持多级分类的路由器
@ -47,7 +47,7 @@ func ExampleNewMultistage() {
```
***
#### func WithRouteTrim(handle func (route any) any) MultistageOption[HandleFunc]
#### func WithRouteTrim(handle func (route any) any) MultistageOption[HandleFunc]
<span id="WithRouteTrim"></span>
> 路由修剪选项
> - 将在路由注册前对路由进行对应处理

View File

@ -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]
<span id="NewChannel"></span>
> 创建基于 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]
<span id="NewUnbounded"></span>
> 创建写循环
> - pool 用于管理 Message 对象的缓冲池,在创建 Message 对象时也应该使用该缓冲池,以便复用 Message 对象。 Unbounded 会在写入完成后将 Message 对象放回缓冲池

View File

@ -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]
<span id="NewTwoDimensional"></span>
<details>

View File

@ -50,54 +50,54 @@ arrangement 包提供了一些有用的函数来处理数组的排列。
***
## 详情信息
#### func WithAreaConstraint(constraint AreaConstraintHandle[ID, AreaInfo]) AreaOption[ID, AreaInfo]
#### func WithAreaConstraint(constraint AreaConstraintHandle[ID, AreaInfo]) AreaOption[ID, AreaInfo]
<span id="WithAreaConstraint"></span>
> 设置编排区域的约束条件
> - 该约束用于判断一个成员是否可以被添加到该编排区域中
> - 与 WithAreaConflict 不同的是,约束通常用于非成员关系导致的硬性约束,例如:成员的等级过滤、成员的性别等
***
#### func WithAreaConflict(conflict AreaConflictHandle[ID, AreaInfo]) AreaOption[ID, AreaInfo]
#### func WithAreaConflict(conflict AreaConflictHandle[ID, AreaInfo]) AreaOption[ID, AreaInfo]
<span id="WithAreaConflict"></span>
> 设置编排区域的冲突条件,冲突处理函数需要返回造成冲突的成员列表
> - 该冲突用于判断一个成员是否可以被添加到该编排区域中
> - 与 WithAreaConstraint 不同的是,冲突通常用于成员关系导致的软性约束,例如:成员的职业唯一性、成员的种族唯一性等
***
#### func WithAreaEvaluate(evaluate AreaEvaluateHandle[ID, AreaInfo]) AreaOption[ID, AreaInfo]
#### func WithAreaEvaluate(evaluate AreaEvaluateHandle[ID, AreaInfo]) AreaOption[ID, AreaInfo]
<span id="WithAreaEvaluate"></span>
> 设置编排区域的评估函数
> - 该评估函数将影响成员被编入区域的优先级
***
#### func NewArrangement(options ...Option[ID, AreaInfo]) *Arrangement[ID, AreaInfo]
#### func NewArrangement(options ...Option[ID, AreaInfo]) *Arrangement[ID, AreaInfo]
<span id="NewArrangement"></span>
> 创建一个新的编排
***
#### func WithItemFixed(matcher ItemFixedAreaHandle[AreaInfo]) ItemOption[ID, AreaInfo]
#### func WithItemFixed(matcher ItemFixedAreaHandle[AreaInfo]) ItemOption[ID, AreaInfo]
<span id="WithItemFixed"></span>
> 设置成员的固定编排区域
***
#### func WithItemPriority(priority ItemPriorityHandle[ID, AreaInfo]) ItemOption[ID, AreaInfo]
#### func WithItemPriority(priority ItemPriorityHandle[ID, AreaInfo]) ItemOption[ID, AreaInfo]
<span id="WithItemPriority"></span>
> 设置成员的优先级
***
#### func WithItemNotAllow(verify ItemNotAllowVerifyHandle[ID, AreaInfo]) ItemOption[ID, AreaInfo]
#### func WithItemNotAllow(verify ItemNotAllowVerifyHandle[ID, AreaInfo]) ItemOption[ID, AreaInfo]
<span id="WithItemNotAllow"></span>
> 设置成员不允许的编排区域
***
#### func WithRetryThreshold(threshold int) Option[ID, AreaInfo]
#### func WithRetryThreshold(threshold int) Option[ID, AreaInfo]
<span id="WithRetryThreshold"></span>
> 设置编排时的重试阈值
> - 当每一轮编排结束任有成员未被编排时,将会进行下一轮编排,直到编排次数达到该阈值
> - 默认的阈值为 10 次
***
#### func WithConstraintHandle(handle ConstraintHandle[ID, AreaInfo]) Option[ID, AreaInfo]
#### func WithConstraintHandle(handle ConstraintHandle[ID, AreaInfo]) Option[ID, AreaInfo]
<span id="WithConstraintHandle"></span>
> 设置编排时触发约束时的处理函数
> - 当约束条件触发时,将会调用该函数。如果无法在该函数中处理约束,应该继续返回 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]
<span id="WithConflictHandle"></span>
> 设置编排时触发冲突时的处理函数
> - 当冲突条件触发时,将会调用该函数。如果无法在该函数中处理冲突,应该继续返回这一批成员,尝试进行下一层的冲突处理

View File

@ -40,7 +40,7 @@ buffer 提供了缓冲区相关的实用程序。
***
## 详情信息
#### func NewRing(initSize ...int) *Ring[T]
#### func NewRing(initSize ...int) *Ring[T]
<span id="NewRing"></span>
> 创建一个并发不安全的环形缓冲区
> - initSize: 初始容量
@ -68,12 +68,12 @@ func TestNewRing(t *testing.T) {
***
#### func NewRingUnbounded(bufferSize int) *RingUnbounded[T]
#### func NewRingUnbounded(bufferSize int) *RingUnbounded[T]
<span id="NewRingUnbounded"></span>
> 创建一个并发安全的基于环形缓冲区实现的无界缓冲区
***
#### func NewUnbounded() *Unbounded[V]
#### func NewUnbounded() *Unbounded[V]
<span id="NewUnbounded"></span>
> 创建一个无界缓冲区
> - generateNil: 生成空值的函数,该函数仅需始终返回 nil 即可
@ -93,7 +93,7 @@ type Ring[T any] struct {
w int
}
```
#### func (*Ring) Read() T, error
#### func (*Ring) Read() ( T, error)
> 读取数据
<details>
<summary>查看 / 收起基准测试</summary>

View File

@ -141,7 +141,7 @@ collection 用于对 input 和 map 操作的工具函数
***
## 详情信息
#### func CloneSlice(slice S) S
#### func CloneSlice(slice S) S
<span id="CloneSlice"></span>
> 克隆切片,该函数是 slices.Clone 的快捷方式
@ -190,7 +190,7 @@ func TestCloneSlice(t *testing.T) {
***
#### func CloneMap(m M) M
#### func CloneMap(m M) M
<span id="CloneMap"></span>
> 克隆 map
@ -239,7 +239,7 @@ func TestCloneMap(t *testing.T) {
***
#### func CloneSliceN(slice S, n int) []S
#### func CloneSliceN(slice S, n int) []S
<span id="CloneSliceN"></span>
> 克隆 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
<span id="CloneMapN"></span>
> 克隆 map 为 n 个 map 进行返回
@ -349,7 +349,7 @@ func TestCloneMapN(t *testing.T) {
***
#### func CloneSlices(slices ...S) []S
#### func CloneSlices(slices ...S) []S
<span id="CloneSlices"></span>
> 克隆多个切片
@ -401,7 +401,7 @@ func TestCloneSlices(t *testing.T) {
***
#### func CloneMaps(maps ...M) []M
#### func CloneMaps(maps ...M) []M
<span id="CloneMaps"></span>
> 克隆多个 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
<span id="InSlice"></span>
> 检查 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
<span id="InComparableSlice"></span>
> 检查 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
<span id="AllInSlice"></span>
> 检查 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
<span id="AllInComparableSlice"></span>
> 检查 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
<span id="AnyInSlice"></span>
> 检查 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
<span id="AnyInComparableSlice"></span>
> 检查 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
<span id="InSlices"></span>
> 通过将多个切片合并后检查 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
<span id="InComparableSlices"></span>
> 通过将多个切片合并后检查 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
<span id="AllInSlices"></span>
> 通过将多个切片合并后检查 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
<span id="AllInComparableSlices"></span>
> 通过将多个切片合并后检查 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
<span id="AnyInSlices"></span>
> 通过将多个切片合并后检查 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
<span id="AnyInComparableSlices"></span>
> 通过将多个切片合并后检查 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
<span id="InAllSlices"></span>
> 检查 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
<span id="InAllComparableSlices"></span>
> 检查 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
<span id="AnyInAllSlices"></span>
> 检查 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
<span id="AnyInAllComparableSlices"></span>
> 检查 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
<span id="KeyInMap"></span>
> 检查 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
<span id="ValueInMap"></span>
> 检查 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
<span id="AllKeyInMap"></span>
> 检查 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
<span id="AllValueInMap"></span>
> 检查 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
<span id="AnyKeyInMap"></span>
> 检查 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
<span id="AnyValueInMap"></span>
> 检查 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
<span id="AllKeyInMaps"></span>
> 检查 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
<span id="AllValueInMaps"></span>
> 检查 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
<span id="AnyKeyInMaps"></span>
> 检查 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
<span id="AnyValueInMaps"></span>
> 检查 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
<span id="KeyInAllMaps"></span>
> 检查 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
<span id="AnyKeyInAllMaps"></span>
> 检查 maps 中的每一个元素是否均包含 keys 中任意一个元素
> - 当 maps 中的每一个元素均包含 keys 中任意一个元素时,返回 true
@ -1747,7 +1747,7 @@ func TestAnyKeyInAllMaps(t *testing.T) {
***
#### func ConvertSliceToAny(s S) []any
#### func ConvertSliceToAny(s S) []any
<span id="ConvertSliceToAny"></span>
> 将切片转换为任意类型的切片
@ -1799,7 +1799,7 @@ func TestConvertSliceToAny(t *testing.T) {
***
#### func ConvertSliceToIndexMap(s S) map[int]V
#### func ConvertSliceToIndexMap(s S) map[int]V
<span id="ConvertSliceToIndexMap"></span>
> 将切片转换为索引为键的映射
@ -1850,7 +1850,7 @@ func TestConvertSliceToIndexMap(t *testing.T) {
***
#### func ConvertSliceToIndexOnlyMap(s S) map[int]struct {}
#### func ConvertSliceToIndexOnlyMap(s S) map[int]struct {}
<span id="ConvertSliceToIndexOnlyMap"></span>
> 将切片转换为索引为键的映射
@ -1905,7 +1905,7 @@ func TestConvertSliceToIndexOnlyMap(t *testing.T) {
***
#### func ConvertSliceToMap(s S) map[V]struct {}
#### func ConvertSliceToMap(s S) map[V]struct {}
<span id="ConvertSliceToMap"></span>
> 将切片转换为值为键的映射
@ -1957,7 +1957,7 @@ func TestConvertSliceToMap(t *testing.T) {
***
#### func ConvertSliceToBoolMap(s S) map[V]bool
#### func ConvertSliceToBoolMap(s S) map[V]bool
<span id="ConvertSliceToBoolMap"></span>
> 将切片转换为值为键的映射
@ -2008,7 +2008,7 @@ func TestConvertSliceToBoolMap(t *testing.T) {
***
#### func ConvertMapKeysToSlice(m M) []K
#### func ConvertMapKeysToSlice(m M) []K
<span id="ConvertMapKeysToSlice"></span>
> 将映射的键转换为切片
@ -2064,7 +2064,7 @@ func TestConvertMapKeysToSlice(t *testing.T) {
***
#### func ConvertMapValuesToSlice(m M) []V
#### func ConvertMapValuesToSlice(m M) []V
<span id="ConvertMapValuesToSlice"></span>
> 将映射的值转换为切片
@ -2121,7 +2121,7 @@ func TestConvertMapValuesToSlice(t *testing.T) {
***
#### func InvertMap(m M) N
#### func InvertMap(m M) N
<span id="InvertMap"></span>
> 将映射的键和值互换
@ -2169,7 +2169,7 @@ func TestInvertMap(t *testing.T) {
***
#### func ConvertMapValuesToBool(m M) N
#### func ConvertMapValuesToBool(m M) N
<span id="ConvertMapValuesToBool"></span>
> 将映射的值转换为布尔值
@ -2592,7 +2592,7 @@ func TestDeduplicateSliceInPlace(t *testing.T) {
***
#### func DeduplicateSlice(s S) S
#### func DeduplicateSlice(s S) S
<span id="DeduplicateSlice"></span>
> 去除切片中的重复元素,返回新切片
@ -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
<span id="DeduplicateSliceWithCompare"></span>
> 去除切片中的重复元素,使用自定义的比较函数,返回新的切片
@ -2748,7 +2748,7 @@ func TestDeduplicateSliceWithCompare(t *testing.T) {
***
#### func FilterOutByIndices(slice S, indices ...int) S
#### func FilterOutByIndices(slice S, indices ...int) S
<span id="FilterOutByIndices"></span>
> 过滤切片中特定索引的元素,返回过滤后的切片
@ -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
<span id="FilterOutByCondition"></span>
> 过滤切片中符合条件的元素,返回过滤后的切片
> - 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
<span id="FilterOutByKey"></span>
> 过滤 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
<span id="FilterOutByValue"></span>
> 过滤 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
<span id="FilterOutByKeys"></span>
> 过滤 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
<span id="FilterOutByValues"></span>
> 过滤 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
<span id="FilterOutByMap"></span>
> 过滤 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
<span id="FindCombinationsInSliceByRange"></span>
> 获取给定数组的所有组合,且每个组合的成员数量限制在指定范围内
@ -3257,7 +3257,7 @@ func TestFindCombinationsInSliceByRange(t *testing.T) {
***
#### func FindFirstOrDefaultInSlice(slice S, defaultValue V) V
#### func FindFirstOrDefaultInSlice(slice S, defaultValue V) V
<span id="FindFirstOrDefaultInSlice"></span>
> 判断切片中是否存在元素,返回第一个元素,不存在则返回默认值
@ -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
<span id="FindIndexInSlice"></span>
> 判断切片中是否存在某个元素,返回第一个匹配的索引,不存在则索引返回 -1
@ -3527,7 +3527,7 @@ func TestFindInComparableSlice(t *testing.T) {
***
#### func FindIndexInComparableSlice(slice S, v V) int
#### func FindIndexInComparableSlice(slice S, v V) int
<span id="FindIndexInComparableSlice"></span>
> 判断切片中是否存在某个元素,返回第一个匹配的索引,不存在则索引返回 -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
<span id="MappingFromSlice"></span>
> 将切片中的元素进行转换
@ -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
<span id="MappingFromMap"></span>
> 将 map 中的元素进行转换
@ -4744,7 +4744,7 @@ func TestChooseRandomMapValueRepeatN(t *testing.T) {
***
#### func ChooseRandomMapKeyAndValueRepeatN(m M, n int) M
#### func ChooseRandomMapKeyAndValueRepeatN(m M, n int) M
<span id="ChooseRandomMapKeyAndValueRepeatN"></span>
> 获取 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
<span id="ChooseRandomMapKeyAndValueN"></span>
> 获取 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
<span id="DescBy"></span>
> 返回降序比较结果
@ -5073,7 +5073,7 @@ func TestDescBy(t *testing.T) {
***
#### func AscBy(a Sort, b Sort) bool
#### func AscBy(a Sort, b Sort) bool
<span id="AscBy"></span>
> 返回升序比较结果
@ -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
<span id="DescByClone"></span>
> 对切片进行降序排序,返回排序后的切片
@ -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
<span id="AscByClone"></span>
> 对切片进行升序排序,返回排序后的切片
@ -5367,7 +5367,7 @@ func TestShuffle(t *testing.T) {
***
#### func ShuffleByClone(slice S) S
#### func ShuffleByClone(slice S) S
<span id="ShuffleByClone"></span>
> 对切片进行随机排序,返回排序后的切片

View File

@ -36,22 +36,22 @@
***
## 详情信息
#### func NewMatrix(dimensions ...int) *Matrix[V]
#### func NewMatrix(dimensions ...int) *Matrix[V]
<span id="NewMatrix"></span>
> 创建一个新的 Matrix 实例。
***
#### func NewPagedSlice(pageSize int) *PagedSlice[T]
#### func NewPagedSlice(pageSize int) *PagedSlice[T]
<span id="NewPagedSlice"></span>
> 创建一个新的 PagedSlice 实例。
***
#### func NewPrioritySlice(lengthAndCap ...int) *PrioritySlice[V]
#### func NewPrioritySlice(lengthAndCap ...int) *PrioritySlice[V]
<span id="NewPrioritySlice"></span>
> 创建一个优先级切片
***
#### func NewSyncSlice(length int, cap int) *SyncSlice[V]
#### func NewSyncSlice(length int, cap int) *SyncSlice[V]
<span id="NewSyncSlice"></span>
> 创建一个 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

View File

@ -30,7 +30,7 @@
***
## 详情信息
#### func NewSyncMap(source ...map[K]V) *SyncMap[K, V]
#### func NewSyncMap(source ...map[K]V) *SyncMap[K, V]
<span id="NewSyncMap"></span>
> 创建一个 SyncMap

View File

@ -65,12 +65,12 @@ combination 包提供了一些实用的组合函数。
***
## 详情信息
#### func NewCombination(options ...Option[T]) *Combination[T]
#### func NewCombination(options ...Option[T]) *Combination[T]
<span id="NewCombination"></span>
> 创建一个新的组合器
***
#### func WithEvaluation(evaluate func (items []T) float64) Option[T]
#### func WithEvaluation(evaluate func (items []T) float64) Option[T]
<span id="WithEvaluation"></span>
> 设置组合评估函数
> - 用于对组合进行评估,返回一个分值的评价函数
@ -79,57 +79,57 @@ combination 包提供了一些实用的组合函数。
> - 默认的评估函数将返回一个随机数
***
#### func NewMatcher(options ...MatcherOption[T]) *Matcher[T]
#### func NewMatcher(options ...MatcherOption[T]) *Matcher[T]
<span id="NewMatcher"></span>
> 创建一个新的匹配器
***
#### func WithMatcherEvaluation(evaluate func (items []T) float64) MatcherOption[T]
#### func WithMatcherEvaluation(evaluate func (items []T) float64) MatcherOption[T]
<span id="WithMatcherEvaluation"></span>
> 设置匹配器评估函数
> - 用于对组合进行评估,返回一个分值的评价函数
> - 通过该选项将覆盖匹配器的默认(WithEvaluation)评估函数
***
#### func WithMatcherLeastLength(length int) MatcherOption[T]
#### func WithMatcherLeastLength(length int) MatcherOption[T]
<span id="WithMatcherLeastLength"></span>
> 通过匹配最小长度的组合创建匹配器
> - length: 组合的长度,表示需要匹配的组合最小数量
***
#### func WithMatcherLength(length int) MatcherOption[T]
#### func WithMatcherLength(length int) MatcherOption[T]
<span id="WithMatcherLength"></span>
> 通过匹配长度的组合创建匹配器
> - length: 组合的长度,表示需要匹配的组合数量
***
#### func WithMatcherMostLength(length int) MatcherOption[T]
#### func WithMatcherMostLength(length int) MatcherOption[T]
<span id="WithMatcherMostLength"></span>
> 通过匹配最大长度的组合创建匹配器
> - length: 组合的长度,表示需要匹配的组合最大数量
***
#### func WithMatcherIntervalLength(min int, max int) MatcherOption[T]
#### func WithMatcherIntervalLength(min int, max int) MatcherOption[T]
<span id="WithMatcherIntervalLength"></span>
> 通过匹配长度区间的组合创建匹配器
> - min: 组合的最小长度,表示需要匹配的组合最小数量
> - max: 组合的最大长度,表示需要匹配的组合最大数量
***
#### func WithMatcherContinuity(getIndex func (item T) Index) MatcherOption[T]
#### func WithMatcherContinuity(getIndex func (item T) Index) MatcherOption[T]
<span id="WithMatcherContinuity"></span>
> 通过匹配连续的组合创建匹配器
> - index: 用于获取组合中元素的索引值,用于判断是否连续
***
#### func WithMatcherSame(count int, getType func (item T) E) MatcherOption[T]
#### func WithMatcherSame(count int, getType func (item T) E) MatcherOption[T]
<span id="WithMatcherSame"></span>
> 通过匹配相同的组合创建匹配器
> - 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]
<span id="WithMatcherNCarryM"></span>
> 通过匹配 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]
<span id="WithMatcherNCarryIndependentM"></span>
> 通过匹配 N 携带独立 M 的组合创建匹配器
> - n: 组合中元素的数量表示需要匹配的组合数量n 的类型需要全部相同
@ -145,87 +145,87 @@ combination 包提供了一些实用的组合函数。
> - getType: 用于获取组合中元素的类型,用于判断是否相同
***
#### func NewValidator(options ...ValidatorOption[T]) *Validator[T]
#### func NewValidator(options ...ValidatorOption[T]) *Validator[T]
<span id="NewValidator"></span>
> 创建一个新的校验器
***
#### func WithValidatorHandle(handle func (items []T) bool) ValidatorOption[T]
#### func WithValidatorHandle(handle func (items []T) bool) ValidatorOption[T]
<span id="WithValidatorHandle"></span>
> 通过特定的验证函数对组合进行验证
***
#### func WithValidatorHandleLength(length int) ValidatorOption[T]
#### func WithValidatorHandleLength(length int) ValidatorOption[T]
<span id="WithValidatorHandleLength"></span>
> 校验组合的长度是否符合要求
***
#### func WithValidatorHandleLengthRange(min int, max int) ValidatorOption[T]
#### func WithValidatorHandleLengthRange(min int, max int) ValidatorOption[T]
<span id="WithValidatorHandleLengthRange"></span>
> 校验组合的长度是否在指定的范围内
***
#### func WithValidatorHandleLengthMin(min int) ValidatorOption[T]
#### func WithValidatorHandleLengthMin(min int) ValidatorOption[T]
<span id="WithValidatorHandleLengthMin"></span>
> 校验组合的长度是否大于等于指定的最小值
***
#### func WithValidatorHandleLengthMax(max int) ValidatorOption[T]
#### func WithValidatorHandleLengthMax(max int) ValidatorOption[T]
<span id="WithValidatorHandleLengthMax"></span>
> 校验组合的长度是否小于等于指定的最大值
***
#### func WithValidatorHandleLengthNot(length int) ValidatorOption[T]
#### func WithValidatorHandleLengthNot(length int) ValidatorOption[T]
<span id="WithValidatorHandleLengthNot"></span>
> 校验组合的长度是否不等于指定的值
***
#### func WithValidatorHandleTypeLength(length int, getType func (item T) E) ValidatorOption[T]
#### func WithValidatorHandleTypeLength(length int, getType func (item T) E) ValidatorOption[T]
<span id="WithValidatorHandleTypeLength"></span>
> 校验组合成员类型数量是否为指定的值
***
#### 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]
<span id="WithValidatorHandleTypeLengthRange"></span>
> 校验组合成员类型数量是否在指定的范围内
***
#### func WithValidatorHandleTypeLengthMin(min int, getType func (item T) E) ValidatorOption[T]
#### func WithValidatorHandleTypeLengthMin(min int, getType func (item T) E) ValidatorOption[T]
<span id="WithValidatorHandleTypeLengthMin"></span>
> 校验组合成员类型数量是否大于等于指定的最小值
***
#### func WithValidatorHandleTypeLengthMax(max int, getType func (item T) E) ValidatorOption[T]
#### func WithValidatorHandleTypeLengthMax(max int, getType func (item T) E) ValidatorOption[T]
<span id="WithValidatorHandleTypeLengthMax"></span>
> 校验组合成员类型数量是否小于等于指定的最大值
***
#### func WithValidatorHandleTypeLengthNot(length int, getType func (item T) E) ValidatorOption[T]
#### func WithValidatorHandleTypeLengthNot(length int, getType func (item T) E) ValidatorOption[T]
<span id="WithValidatorHandleTypeLengthNot"></span>
> 校验组合成员类型数量是否不等于指定的值
***
#### func WithValidatorHandleContinuous(getIndex func (item T) Index) ValidatorOption[T]
#### func WithValidatorHandleContinuous(getIndex func (item T) Index) ValidatorOption[T]
<span id="WithValidatorHandleContinuous"></span>
> 校验组合成员是否连续
***
#### func WithValidatorHandleContinuousNot(getIndex func (item T) Index) ValidatorOption[T]
#### func WithValidatorHandleContinuousNot(getIndex func (item T) Index) ValidatorOption[T]
<span id="WithValidatorHandleContinuousNot"></span>
> 校验组合成员是否不连续
***
#### 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]
<span id="WithValidatorHandleGroupContinuous"></span>
> 校验组合成员是否能够按类型分组并且连续
***
#### 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]
<span id="WithValidatorHandleGroupContinuousN"></span>
> 校验组合成员是否能够按分组为 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]
<span id="WithValidatorHandleNCarryM"></span>
> 校验组合成员是否匹配 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]
<span id="WithValidatorHandleNCarryIndependentM"></span>
> 校验组合成员是否匹配 N 携带独立的 M 的组合
> - n: 组合中元素的数量表示需要匹配的组合数量n 的类型需要全部相同

View File

@ -30,32 +30,32 @@ compress 提供了一些用于压缩和解压缩数据的函数。
***
## 详情信息
#### func GZipCompress(data []byte) bytes.Buffer, error
#### func GZipCompress(data []byte) (bytes.Buffer, error)
<span id="GZipCompress"></span>
> 对数据进行GZip压缩返回bytes.Buffer和错误信息
***
#### func GZipUnCompress(dataByte []byte) []byte, error
#### func GZipUnCompress(dataByte []byte) ([]byte, error)
<span id="GZipUnCompress"></span>
> 对已进行GZip压缩的数据进行解压缩返回字节数组及错误信息
***
#### func TARCompress(data []byte) bytes.Buffer, error
#### func TARCompress(data []byte) (bytes.Buffer, error)
<span id="TARCompress"></span>
> 对数据进行TAR压缩返回bytes.Buffer和错误信息
***
#### func TARUnCompress(dataByte []byte) []byte, error
#### func TARUnCompress(dataByte []byte) ([]byte, error)
<span id="TARUnCompress"></span>
> 对已进行TAR压缩的数据进行解压缩返回字节数组及错误信息
***
#### func ZIPCompress(data []byte) bytes.Buffer, error
#### func ZIPCompress(data []byte) (bytes.Buffer, error)
<span id="ZIPCompress"></span>
> 对数据进行ZIP压缩返回bytes.Buffer和错误信息
***
#### func ZIPUnCompress(dataByte []byte) []byte, error
#### func ZIPUnCompress(dataByte []byte) ([]byte, error)
<span id="ZIPUnCompress"></span>
> 对已进行ZIP压缩的数据进行解压缩返回字节数组及错误信息

View File

@ -34,52 +34,52 @@
***
## 详情信息
#### func EncryptBase64(data []byte) string
#### func EncryptBase64(data []byte) string
<span id="EncryptBase64"></span>
> 对数据进行Base64编码
***
#### func DecodedBase64(data string) []byte, error
#### func DecodedBase64(data string) ([]byte, error)
<span id="DecodedBase64"></span>
> 对数据进行Base64解码
***
#### func EncryptCRC32(str string) uint32
#### func EncryptCRC32(str string) uint32
<span id="EncryptCRC32"></span>
> 对字符串进行CRC加密并返回其结果。
***
#### func DecodedCRC32(data []byte) uint32
#### func DecodedCRC32(data []byte) uint32
<span id="DecodedCRC32"></span>
> 对字节数组进行CRC加密并返回其结果。
***
#### func EncryptMD5(str string) string
#### func EncryptMD5(str string) string
<span id="EncryptMD5"></span>
> 对字符串进行MD5加密并返回其结果。
***
#### func DecodedMD5(data []byte) string
#### func DecodedMD5(data []byte) string
<span id="DecodedMD5"></span>
> 对字节数组进行MD5加密并返回其结果。
***
#### func EncryptSHA1(str string) string
#### func EncryptSHA1(str string) string
<span id="EncryptSHA1"></span>
> 对字符串进行SHA1加密并返回其结果。
***
#### func DecodedSHA1(data []byte) string
#### func DecodedSHA1(data []byte) string
<span id="DecodedSHA1"></span>
> 对字节数组进行SHA1加密并返回其结果。
***
#### func EncryptSHA256(str string) string
#### func EncryptSHA256(str string) string
<span id="EncryptSHA256"></span>
> 对字符串进行SHA256加密并返回其结果。
***
#### func DecodedSHA256(data []byte) string
#### func DecodedSHA256(data []byte) string
<span id="DecodedSHA256"></span>
> 对字节数组进行SHA256加密并返回其结果。

View File

@ -33,12 +33,12 @@ deck 包中的内容用于针对一堆内容的管理,适用但不限于牌堆
***
## 详情信息
#### func NewDeck() *Deck[I]
#### func NewDeck() *Deck[I]
<span id="NewDeck"></span>
> 创建一个新的甲板
***
#### func NewGroup(guid int64, fillHandle func (guid int64) []I) *Group[I]
#### func NewGroup(guid int64, fillHandle func (guid int64) []I) *Group[I]
<span id="NewGroup"></span>
> 创建一个新的组

View File

@ -35,46 +35,46 @@
***
## 详情信息
#### func PathExist(path string) bool, error
#### func PathExist(path string) (bool, error)
<span id="PathExist"></span>
> 路径是否存在
***
#### func IsDir(path string) bool, error
#### func IsDir(path string) (bool, error)
<span id="IsDir"></span>
> 路径是否是文件夹
***
#### func WriterFile(filePath string, content []byte) error
#### func WriterFile(filePath string, content []byte) error
<span id="WriterFile"></span>
> 向特定文件写入内容
***
#### func ReadOnce(filePath string) []byte, error
#### func ReadOnce(filePath string) ([]byte, error)
<span id="ReadOnce"></span>
> 单次读取文件
> - 一次性对整个文件进行读取,小文件读取可以很方便的一次性将文件内容读取出来,而大文件读取会造成性能影响。
***
#### func ReadBlockHook(filePath string, bufferSize int, hook func (data []byte)) error
#### func ReadBlockHook(filePath string, bufferSize int, hook func (data []byte)) error
<span id="ReadBlockHook"></span>
> 分块读取文件
> - 将filePath路径对应的文件数据并将读到的每一部分传入hook函数中当过程中如果产生错误则会返回error。
> - 分块读取可以在读取速度和内存消耗之间有一个很好的平衡。
***
#### func ReadLine(filePath string, hook func (line string)) error
#### func ReadLine(filePath string, hook func (line string)) error
<span id="ReadLine"></span>
> 分行读取文件
> - 将filePath路径对应的文件数据并将读到的每一行传入hook函数中当过程中如果产生错误则会返回error。
***
#### func LineCount(filePath string) int
#### func LineCount(filePath string) int
<span id="LineCount"></span>
> 统计文件行数
***
#### func Paths(dir string) []string
#### func Paths(dir string) []string
<span id="Paths"></span>
> 获取指定目录下的所有文件路径
> - 包括了子目录下的文件
@ -88,7 +88,7 @@
> - 可通过 start 参数指定开始读取的位置,如果不指定则从文件开头开始读取。
***
#### func FindLineChunks(file *os.File, chunkSize int64) [][2]int64
#### func FindLineChunks(file *os.File, chunkSize int64) [][2]int64
<span id="FindLineChunks"></span>
> 查找文件按照每行划分的分块,每个分块的大小将在 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
<span id="FindLineChunksByOffset"></span>
> 该函数与 FindLineChunks 类似,不同的是该函数可以指定 offset 从指定位置开始读取文件

View File

@ -36,34 +36,34 @@
***
## 详情信息
#### func NewFSM(data Data) *FSM[State, Data]
#### func NewFSM(data Data) *FSM[State, Data]
<span id="NewFSM"></span>
> 创建一个新的状态机
***
#### func WithEnterBeforeEvent(fn func (state *FSM[State, Data])) Option[State, Data]
#### func WithEnterBeforeEvent(fn func (state *FSM[State, Data])) Option[State, Data]
<span id="WithEnterBeforeEvent"></span>
> 设置状态进入前的回调
> - 在首次设置状态时,状态机本身的当前状态为零值状态
***
#### func WithEnterAfterEvent(fn func (state *FSM[State, Data])) Option[State, Data]
#### func WithEnterAfterEvent(fn func (state *FSM[State, Data])) Option[State, Data]
<span id="WithEnterAfterEvent"></span>
> 设置状态进入后的回调
***
#### func WithUpdateEvent(fn func (state *FSM[State, Data])) Option[State, Data]
#### func WithUpdateEvent(fn func (state *FSM[State, Data])) Option[State, Data]
<span id="WithUpdateEvent"></span>
> 设置状态内刷新的回调
***
#### func WithExitBeforeEvent(fn func (state *FSM[State, Data])) Option[State, Data]
#### func WithExitBeforeEvent(fn func (state *FSM[State, Data])) Option[State, Data]
<span id="WithExitBeforeEvent"></span>
> 设置状态退出前的回调
> - 该阶段状态机的状态为退出前的状态,而非新的状态
***
#### func WithExitAfterEvent(fn func (state *FSM[State, Data])) Option[State, Data]
#### func WithExitAfterEvent(fn func (state *FSM[State, Data])) Option[State, Data]
<span id="WithExitAfterEvent"></span>
> 设置状态退出后的回调
> - 该阶段状态机的状态为新的状态,而非退出前的状态

View File

@ -36,7 +36,7 @@
***
## 详情信息
#### func NewPackage(dir string) *Package, error
#### func NewPackage(dir string) (*Package, error)
<span id="NewPackage"></span>
<details>

View File

@ -30,7 +30,7 @@
***
## 详情信息
#### func New(pkgDirPath string, output string) *Builder, error
#### func New(pkgDirPath string, output string) (*Builder, error)
<span id="New"></span>
***
@ -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"))

View File

@ -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(`<span id="%s"></span>`, 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 {

View File

@ -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(

View File

@ -48,17 +48,17 @@ generic 目的在于提供一组基于泛型的用于处理通用功能的函数
***
## 详情信息
#### func IsNil(v V) bool
#### func IsNil(v V) bool
<span id="IsNil"></span>
> 检查指定的值是否为 nil
***
#### func IsAllNil(v ...V) bool
#### func IsAllNil(v ...V) bool
<span id="IsAllNil"></span>
> 检查指定的值是否全部为 nil
***
#### func IsHasNil(v ...V) bool
#### func IsHasNil(v ...V) bool
<span id="IsHasNil"></span>
> 检查指定的值是否存在 nil

View File

@ -132,7 +132,7 @@ geometry 旨在提供一组用于处理几何形状和计算几何属性的函
***
## 详情信息
#### func NewCircle(radius V, points int) Circle[V]
#### func NewCircle(radius V, points int) Circle[V]
<span id="NewCircle"></span>
> 通过传入圆的半径和需要的点数量,生成一个圆
@ -146,12 +146,12 @@ func ExampleNewCircle() {
```
***
#### func CalcCircleCentroidDistance(circle1 Circle[V], circle2 Circle[V]) V
#### func CalcCircleCentroidDistance(circle1 Circle[V], circle2 Circle[V]) V
<span id="CalcCircleCentroidDistance"></span>
> 计算两个圆质心距离
***
#### func GetOppositionDirection(direction Direction) Direction
#### func GetOppositionDirection(direction Direction) Direction
<span id="GetOppositionDirection"></span>
> 获取特定方向的对立方向
@ -161,39 +161,39 @@ func ExampleNewCircle() {
> 获取特定方向上的下一个坐标
***
#### func GetDirectionNextWithPoint(direction Direction, point Point[V]) Point[V]
#### func GetDirectionNextWithPoint(direction Direction, point Point[V]) Point[V]
<span id="GetDirectionNextWithPoint"></span>
> 获取特定方向上的下一个坐标
***
#### func GetDirectionNextWithPos(direction Direction, width V, pos V) V
#### func GetDirectionNextWithPos(direction Direction, width V, pos V) V
<span id="GetDirectionNextWithPos"></span>
> 获取位置在特定宽度和特定方向上的下一个位置
> - 需要注意的是,在左右方向时,当下一个位置不在矩形区域内时,将会返回上一行的末位置或下一行的首位置
***
#### func CalcDirection(x1 V, y1 V, x2 V, y2 V) Direction
#### func CalcDirection(x1 V, y1 V, x2 V, y2 V) Direction
<span id="CalcDirection"></span>
> 计算点2位于点1的方向
***
#### func CalcDistanceWithCoordinate(x1 V, y1 V, x2 V, y2 V) V
#### func CalcDistanceWithCoordinate(x1 V, y1 V, x2 V, y2 V) V
<span id="CalcDistanceWithCoordinate"></span>
> 计算两点之间的距离
***
#### func CalcDistanceWithPoint(point1 Point[V], point2 Point[V]) V
#### func CalcDistanceWithPoint(point1 Point[V], point2 Point[V]) V
<span id="CalcDistanceWithPoint"></span>
> 计算两点之间的距离
***
#### func CalcDistanceSquared(x1 V, y1 V, x2 V, y2 V) V
#### func CalcDistanceSquared(x1 V, y1 V, x2 V, y2 V) V
<span id="CalcDistanceSquared"></span>
> 计算两点之间的平方距离
> - 这个函数的主要用途是在需要计算两点之间距离的情况下,但不需要得到实际的距离值,而只需要比较距离大小。因为平方根运算相对较为耗时,所以在只需要比较大小的情况下,通常会使用平方距离。
***
#### func CalcAngle(x1 V, y1 V, x2 V, y2 V) V
#### func CalcAngle(x1 V, y1 V, x2 V, y2 V) V
<span id="CalcAngle"></span>
> 计算点2位于点1之间的角度
@ -203,75 +203,75 @@ func ExampleNewCircle() {
> 根据给定的x、y坐标、角度和距离计算新的坐标
***
#### func CalcRadianWithAngle(angle V) V
#### func CalcRadianWithAngle(angle V) V
<span id="CalcRadianWithAngle"></span>
> 根据角度 angle 计算弧度
***
#### func CalcAngleDifference(angleA V, angleB V) V
#### func CalcAngleDifference(angleA V, angleB V) V
<span id="CalcAngleDifference"></span>
> 计算两个角度之间的最小角度差
***
#### func CalcRayIsIntersect(x V, y V, angle V, shape Shape[V]) bool
#### func CalcRayIsIntersect(x V, y V, angle V, shape Shape[V]) bool
<span id="CalcRayIsIntersect"></span>
> 根据给定的位置和角度生成射线,检测射线是否与多边形发生碰撞
***
#### func NewLineSegment(start Point[V], end Point[V]) LineSegment[V]
#### func NewLineSegment(start Point[V], end Point[V]) LineSegment[V]
<span id="NewLineSegment"></span>
> 创建一根线段
***
#### 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]
<span id="NewLineSegmentCap"></span>
> 创建一根包含数据的线段
***
#### func NewLineSegmentCapWithLine(line LineSegment[V], data Data) LineSegmentCap[V, Data]
#### func NewLineSegmentCapWithLine(line LineSegment[V], data Data) LineSegmentCap[V, Data]
<span id="NewLineSegmentCapWithLine"></span>
> 通过已有线段创建一根包含数据的线段
***
#### func ConvertLineSegmentGeneric(line LineSegment[V]) LineSegment[TO]
#### func ConvertLineSegmentGeneric(line LineSegment[V]) LineSegment[TO]
<span id="ConvertLineSegmentGeneric"></span>
> 转换线段的泛型类型为特定类型
***
#### 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
<span id="PointOnLineSegmentWithCoordinate"></span>
> 通过一个线段两个点的位置和一个点的坐标,判断这个点是否在一条线段上
***
#### func PointOnLineSegmentWithPos(width V, pos1 V, pos2 V, pos V) bool
#### func PointOnLineSegmentWithPos(width V, pos1 V, pos2 V, pos V) bool
<span id="PointOnLineSegmentWithPos"></span>
> 通过一个线段两个点的位置和一个点的坐标,判断这个点是否在一条线段上
***
#### func PointOnLineSegmentWithPoint(point1 Point[V], point2 Point[V], point Point[V]) bool
#### func PointOnLineSegmentWithPoint(point1 Point[V], point2 Point[V], point Point[V]) bool
<span id="PointOnLineSegmentWithPoint"></span>
> 通过一个线段两个点的位置和一个点的坐标,判断这个点是否在一条线段上
***
#### 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
<span id="PointOnLineSegmentWithCoordinateInBounds"></span>
> 通过一个线段两个点的位置和一个点的坐标,判断这个点是否在一条线段上
> - 与 PointOnLineSegmentWithCoordinate 不同的是, PointOnLineSegmentWithCoordinateInBounds 中会判断线段及点的位置是否正确
***
#### func PointOnLineSegmentWithPosInBounds(width V, pos1 V, pos2 V, pos V) bool
#### func PointOnLineSegmentWithPosInBounds(width V, pos1 V, pos2 V, pos V) bool
<span id="PointOnLineSegmentWithPosInBounds"></span>
> 通过一个线段两个点的位置和一个点的坐标,判断这个点是否在一条线段上
> - 与 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
<span id="PointOnLineSegmentWithPointInBounds"></span>
> 通过一个线段两个点的位置和一个点的坐标,判断这个点是否在一条线段上
> - 与 PointOnLineSegmentWithPoint 不同的是, PointOnLineSegmentWithPointInBounds 中会判断线段及点的位置是否正确
***
#### func CalcLineSegmentIsCollinear(line1 LineSegment[V], line2 LineSegment[V], tolerance V) bool
#### func CalcLineSegmentIsCollinear(line1 LineSegment[V], line2 LineSegment[V], tolerance V) bool
<span id="CalcLineSegmentIsCollinear"></span>
> 检查两条线段在一个误差内是否共线
> - 共线是指两条线段在同一直线上,即它们的延长线可以重合
@ -282,7 +282,7 @@ func ExampleNewCircle() {
> 通过对点进行排序来检查两条共线线段是否重叠,返回重叠线段
***
#### func CalcLineSegmentIsIntersect(line1 LineSegment[V], line2 LineSegment[V]) bool
#### func CalcLineSegmentIsIntersect(line1 LineSegment[V], line2 LineSegment[V]) bool
<span id="CalcLineSegmentIsIntersect"></span>
> 计算两条线段是否相交
@ -305,17 +305,17 @@ func TestCalcLineSegmentIsIntersect(t *testing.T) {
***
#### func CalcLineSegmentSlope(line LineSegment[V]) V
#### func CalcLineSegmentSlope(line LineSegment[V]) V
<span id="CalcLineSegmentSlope"></span>
> 计算线段的斜率
***
#### func CalcLineSegmentIntercept(line LineSegment[V]) V
#### func CalcLineSegmentIntercept(line LineSegment[V]) V
<span id="CalcLineSegmentIntercept"></span>
> 计算线段的截距
***
#### func NewPoint(x V, y V) Point[V]
#### func NewPoint(x V, y V) Point[V]
<span id="NewPoint"></span>
> 创建一个由 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]
<span id="NewPointCap"></span>
> 创建一个由 x、y 坐标组成的点,这个点具有一个数据容量
***
#### func NewPointCapWithData(x V, y V, data D) PointCap[V, D]
#### func NewPointCapWithData(x V, y V, data D) PointCap[V, D]
<span id="NewPointCapWithData"></span>
> 通过设置数据的方式创建一个由 x、y 坐标组成的点,这个点具有一个数据容量
***
#### func NewPointCapWithPoint(point Point[V], data D) PointCap[V, D]
#### func NewPointCapWithPoint(point Point[V], data D) PointCap[V, D]
<span id="NewPointCapWithPoint"></span>
> 通过设置数据的方式创建一个由已有坐标组成的点,这个点具有一个数据容量
***
#### func CoordinateToPoint(x V, y V) Point[V]
#### func CoordinateToPoint(x V, y V) Point[V]
<span id="CoordinateToPoint"></span>
> 将坐标转换为x、y的坐标数组
***
#### func CoordinateToPos(width V, x V, y V) V
#### func CoordinateToPos(width V, x V, y V) V
<span id="CoordinateToPos"></span>
> 将坐标转换为二维数组的顺序位置坐标
> - 需要确保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
<span id="PointToPos"></span>
> 将坐标转换为二维数组的顺序位置
> - 需要确保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]
<span id="PosToPoint"></span>
> 通过宽度将一个二维数组的顺序位置转换为x、y的坐标数组
***
#### func PosToCoordinateX(width V, pos V) V
#### func PosToCoordinateX(width V, pos V) V
<span id="PosToCoordinateX"></span>
> 通过宽度将一个二维数组的顺序位置转换为X坐标
***
#### func PosToCoordinateY(width V, pos V) V
#### func PosToCoordinateY(width V, pos V) V
<span id="PosToCoordinateY"></span>
> 通过宽度将一个二维数组的顺序位置转换为Y坐标
***
#### func PointCopy(point Point[V]) Point[V]
#### func PointCopy(point Point[V]) Point[V]
<span id="PointCopy"></span>
> 复制一个坐标数组
***
#### func PointToPosWithMulti(width V, points ...Point[V]) []V
#### func PointToPosWithMulti(width V, points ...Point[V]) []V
<span id="PointToPosWithMulti"></span>
> 将一组坐标转换为二维数组的顺序位置
> - 需要确保x的取值范围必须小于width或者将会得到不正确的值
***
#### func PosToPointWithMulti(width V, positions ...V) []Point[V]
#### func PosToPointWithMulti(width V, positions ...V) []Point[V]
<span id="PosToPointWithMulti"></span>
> 将一组二维数组的顺序位置转换为一组数组坐标
***
#### func PosSameRow(width V, pos1 V, pos2 V) bool
#### func PosSameRow(width V, pos1 V, pos2 V) bool
<span id="PosSameRow"></span>
> 返回两个顺序位置在同一宽度是否位于同一行
@ -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]
<span id="CalcProjectionPoint"></span>
> 计算一个点到一条线段的最近点(即投影点)的。这个函数接收一个点和一条线段作为输入,线段由两个端点组成。
> - 该函数的主要用于需要计算一个点到一条线段的最近点的情况下
@ -675,7 +675,7 @@ func TestGenerateShapeOnRectangle(t *testing.T) {
> 获取一个矩形填充满后包含的所有位置
***
#### func CalcRectangleCentroid(shape Shape[V]) Point[V]
#### func CalcRectangleCentroid(shape Shape[V]) Point[V]
<span id="CalcRectangleCentroid"></span>
> 计算矩形质心
> - 非多边形质心计算,仅为顶点的平均值 - 该区域中多边形因子的适当质心
@ -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]
<span id="NewShape"></span>
> 通过多个点生成一个形状进行返回
@ -775,91 +775,91 @@ func TestNewShapeWithString(t *testing.T) {
***
#### func CalcBoundingRadius(shape Shape[V]) V
#### func CalcBoundingRadius(shape Shape[V]) V
<span id="CalcBoundingRadius"></span>
> 计算多边形转换为圆的半径
***
#### func CalcBoundingRadiusWithCentroid(shape Shape[V], centroid Point[V]) V
#### func CalcBoundingRadiusWithCentroid(shape Shape[V], centroid Point[V]) V
<span id="CalcBoundingRadiusWithCentroid"></span>
> 计算多边形在特定质心下圆的半径
***
#### func CalcTriangleTwiceArea(a Point[V], b Point[V], c Point[V]) V
#### func CalcTriangleTwiceArea(a Point[V], b Point[V], c Point[V]) V
<span id="CalcTriangleTwiceArea"></span>
> 计算由 a、b、c 三个点组成的三角形的面积的两倍
***
#### func IsPointOnEdge(edges []LineSegment[V], point Point[V]) bool
#### func IsPointOnEdge(edges []LineSegment[V], point Point[V]) bool
<span id="IsPointOnEdge"></span>
> 检查点是否在 edges 的任意一条边上
***
#### func ProjectionPointToShape(point Point[V], shape Shape[V]) Point[V], V
#### func ProjectionPointToShape(point Point[V], shape Shape[V]) (Point[V], V)
<span id="ProjectionPointToShape"></span>
> 将一个点投影到一个多边形上,找到离该点最近的投影点,并返回投影点和距离
***
#### func WithShapeSearchRectangleLowerLimit(minWidth int, minHeight int) ShapeSearchOption
#### func WithShapeSearchRectangleLowerLimit(minWidth int, minHeight int) ShapeSearchOption
<span id="WithShapeSearchRectangleLowerLimit"></span>
> 通过矩形宽高下限的方式搜索
***
#### func WithShapeSearchRectangleUpperLimit(maxWidth int, maxHeight int) ShapeSearchOption
#### func WithShapeSearchRectangleUpperLimit(maxWidth int, maxHeight int) ShapeSearchOption
<span id="WithShapeSearchRectangleUpperLimit"></span>
> 通过矩形宽高上限的方式搜索
***
#### func WithShapeSearchRightAngle() ShapeSearchOption
#### func WithShapeSearchRightAngle() ShapeSearchOption
<span id="WithShapeSearchRightAngle"></span>
> 通过直角的方式进行搜索
***
#### func WithShapeSearchOppositionDirection(direction Direction) ShapeSearchOption
#### func WithShapeSearchOppositionDirection(direction Direction) ShapeSearchOption
<span id="WithShapeSearchOppositionDirection"></span>
> 通过限制对立方向的方式搜索
> - 对立方向例如上不能与下共存
***
#### func WithShapeSearchDirectionCount(count int) ShapeSearchOption
#### func WithShapeSearchDirectionCount(count int) ShapeSearchOption
<span id="WithShapeSearchDirectionCount"></span>
> 通过限制方向数量的方式搜索
***
#### func WithShapeSearchDirectionCountLowerLimit(direction Direction, count int) ShapeSearchOption
#### func WithShapeSearchDirectionCountLowerLimit(direction Direction, count int) ShapeSearchOption
<span id="WithShapeSearchDirectionCountLowerLimit"></span>
> 通过限制特定方向数量下限的方式搜索
***
#### func WithShapeSearchDirectionCountUpperLimit(direction Direction, count int) ShapeSearchOption
#### func WithShapeSearchDirectionCountUpperLimit(direction Direction, count int) ShapeSearchOption
<span id="WithShapeSearchDirectionCountUpperLimit"></span>
> 通过限制特定方向数量上限的方式搜索
***
#### func WithShapeSearchDeduplication() ShapeSearchOption
#### func WithShapeSearchDeduplication() ShapeSearchOption
<span id="WithShapeSearchDeduplication"></span>
> 通过去重的方式进行搜索
> - 去重方式中每个点仅会被使用一次
***
#### func WithShapeSearchPointCountLowerLimit(lowerLimit int) ShapeSearchOption
#### func WithShapeSearchPointCountLowerLimit(lowerLimit int) ShapeSearchOption
<span id="WithShapeSearchPointCountLowerLimit"></span>
> 通过限制图形构成的最小点数进行搜索
> - 当搜索到的图形的点数量低于 lowerLimit 时,将被忽略
***
#### func WithShapeSearchPointCountUpperLimit(upperLimit int) ShapeSearchOption
#### func WithShapeSearchPointCountUpperLimit(upperLimit int) ShapeSearchOption
<span id="WithShapeSearchPointCountUpperLimit"></span>
> 通过限制图形构成的最大点数进行搜索
> - 当搜索到的图形的点数量大于 upperLimit 时,将被忽略
***
#### func WithShapeSearchAsc() ShapeSearchOption
#### func WithShapeSearchAsc() ShapeSearchOption
<span id="WithShapeSearchAsc"></span>
> 通过升序的方式进行搜索
***
#### func WithShapeSearchDesc() ShapeSearchOption
#### func WithShapeSearchDesc() ShapeSearchOption
<span id="WithShapeSearchDesc"></span>
> 通过降序的方式进行搜索

View File

@ -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
<span id="Find"></span>
> 使用 A* 算法在导航网格上查找从起点到终点的最短路径,并返回路径上的节点序列。
>

View File

@ -35,7 +35,7 @@ dp (DistributionPattern) 提供用于在二维数组中根据不同的特征标
***
## 详情信息
#### func NewDistributionPattern(sameKindVerifyHandle func (itemA Item) bool) *DistributionPattern[Item]
#### func NewDistributionPattern(sameKindVerifyHandle func (itemA Item) bool) *DistributionPattern[Item]
<span id="NewDistributionPattern"></span>
> 构建一个分布图实例

View File

@ -30,7 +30,7 @@ matrix 提供了一个简单的二维数组的实现
***
## 详情信息
#### func NewMatrix(width int, height int) *Matrix[T]
#### func NewMatrix(width int, height int) *Matrix[T]
<span id="NewMatrix"></span>
> 生成特定宽高的二维矩阵
> - 虽然提供了通过x、y坐标的操作函数但是建议无论如何使用pos进行处理

View File

@ -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]
<span id="NewNavMesh"></span>
> 创建一个新的导航网格,并返回一个指向该导航网格的指针。
>

View File

@ -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]
<span id="NewObjectPool"></span>
> 创建一个 ObjectPool

View File

@ -34,23 +34,23 @@
***
## 详情信息
#### func NewFloat(x T) *Float
#### func NewFloat(x T) *Float
<span id="NewFloat"></span>
> 创建一个 Float
***
#### func NewFloatByString(i string) *Float
#### func NewFloatByString(i string) *Float
<span id="NewFloatByString"></span>
> 通过字符串创建一个 Float
> - 如果字符串不是一个合法的数字,则返回 0
***
#### func NewInt(x T) *Int
#### func NewInt(x T) *Int
<span id="NewInt"></span>
> 创建一个 Int
***
#### func NewIntByString(i string) *Int
#### func NewIntByString(i string) *Int
<span id="NewIntByString"></span>
> 通过字符串创建一个 Int
> - 如果字符串不是一个合法的数字,则返回 0

View File

@ -34,7 +34,7 @@
***
## 详情信息
#### func NewBinarySearch(options ...BinarySearchOption[CompetitorID, Score]) *BinarySearch[CompetitorID, Score]
#### func NewBinarySearch(options ...BinarySearchOption[CompetitorID, Score]) *BinarySearch[CompetitorID, Score]
<span id="NewBinarySearch"></span>
> 创建一个基于内存的二分查找排行榜
@ -49,13 +49,13 @@ func ExampleNewBinarySearch() {
```
***
#### func WithBinarySearchCount(rankCount int) BinarySearchOption[CompetitorID, Score]
#### func WithBinarySearchCount(rankCount int) BinarySearchOption[CompetitorID, Score]
<span id="WithBinarySearchCount"></span>
> 通过限制排行榜竞争者数量来创建排行榜
> - 默认情况下允许100位竞争者
***
#### func WithBinarySearchASC() BinarySearchOption[CompetitorID, Score]
#### func WithBinarySearchASC() BinarySearchOption[CompetitorID, Score]
<span id="WithBinarySearchASC"></span>
> 通过升序的方式创建排行榜
> - 默认情况下为降序

View File

@ -96,7 +96,7 @@
<span id="Println"></span>
***
#### func Default() *Logger
#### func Default() *Logger
<span id="Default"></span>
> 获取默认的日志记录器
@ -150,193 +150,193 @@
> - 然后记录器调用 os.Exit(1),即使 FatalLevel 的日志记录被禁用
***
#### func Skip(vs ...any) slog.Attr
#### func Skip(vs ...any) slog.Attr
<span id="Skip"></span>
> 构造一个无操作字段,这在处理其他 Field 构造函数中的无效输入时通常很有用
> - 该函数还支持将其他字段快捷的转换为 Skip 字段
***
#### func Duration(key string, val time.Duration) slog.Attr
#### func Duration(key string, val time.Duration) slog.Attr
<span id="Duration"></span>
> 使用给定的键和值构造一个字段。编码器控制持续时间的序列化方式
***
#### func DurationP(key string, val *time.Duration) slog.Attr
#### func DurationP(key string, val *time.Duration) slog.Attr
<span id="DurationP"></span>
> 构造一个带有 time.Duration 的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Bool(key string, val bool) slog.Attr
#### func Bool(key string, val bool) slog.Attr
<span id="Bool"></span>
> 构造一个带有布尔值的字段
***
#### func BoolP(key string, val *bool) slog.Attr
#### func BoolP(key string, val *bool) slog.Attr
<span id="BoolP"></span>
> 构造一个带有布尔值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func String(key string, val string) slog.Attr
#### func String(key string, val string) slog.Attr
<span id="String"></span>
> 构造一个带有字符串值的字段
***
#### func StringP(key string, val *string) slog.Attr
#### func StringP(key string, val *string) slog.Attr
<span id="StringP"></span>
> 构造一个带有字符串值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Int(key string, val I) slog.Attr
#### func Int(key string, val I) slog.Attr
<span id="Int"></span>
> 构造一个带有整数值的字段
***
#### func IntP(key string, val *I) slog.Attr
#### func IntP(key string, val *I) slog.Attr
<span id="IntP"></span>
> 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Int8(key string, val I) slog.Attr
#### func Int8(key string, val I) slog.Attr
<span id="Int8"></span>
> 构造一个带有整数值的字段
***
#### func Int8P(key string, val *I) slog.Attr
#### func Int8P(key string, val *I) slog.Attr
<span id="Int8P"></span>
> 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Int16(key string, val I) slog.Attr
#### func Int16(key string, val I) slog.Attr
<span id="Int16"></span>
> 构造一个带有整数值的字段
***
#### func Int16P(key string, val *I) slog.Attr
#### func Int16P(key string, val *I) slog.Attr
<span id="Int16P"></span>
> 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Int32(key string, val I) slog.Attr
#### func Int32(key string, val I) slog.Attr
<span id="Int32"></span>
> 构造一个带有整数值的字段
***
#### func Int32P(key string, val *I) slog.Attr
#### func Int32P(key string, val *I) slog.Attr
<span id="Int32P"></span>
> 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Int64(key string, val I) slog.Attr
#### func Int64(key string, val I) slog.Attr
<span id="Int64"></span>
> 构造一个带有整数值的字段
***
#### func Int64P(key string, val *I) slog.Attr
#### func Int64P(key string, val *I) slog.Attr
<span id="Int64P"></span>
> 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Uint(key string, val I) slog.Attr
#### func Uint(key string, val I) slog.Attr
<span id="Uint"></span>
> 构造一个带有整数值的字段
***
#### func UintP(key string, val *I) slog.Attr
#### func UintP(key string, val *I) slog.Attr
<span id="UintP"></span>
> 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Uint8(key string, val I) slog.Attr
#### func Uint8(key string, val I) slog.Attr
<span id="Uint8"></span>
> 构造一个带有整数值的字段
***
#### func Uint8P(key string, val *I) slog.Attr
#### func Uint8P(key string, val *I) slog.Attr
<span id="Uint8P"></span>
> 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Uint16(key string, val I) slog.Attr
#### func Uint16(key string, val I) slog.Attr
<span id="Uint16"></span>
> 构造一个带有整数值的字段
***
#### func Uint16P(key string, val *I) slog.Attr
#### func Uint16P(key string, val *I) slog.Attr
<span id="Uint16P"></span>
> 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Uint32(key string, val I) slog.Attr
#### func Uint32(key string, val I) slog.Attr
<span id="Uint32"></span>
> 构造一个带有整数值的字段
***
#### func Uint32P(key string, val *I) slog.Attr
#### func Uint32P(key string, val *I) slog.Attr
<span id="Uint32P"></span>
> 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Uint64(key string, val I) slog.Attr
#### func Uint64(key string, val I) slog.Attr
<span id="Uint64"></span>
> 构造一个带有整数值的字段
***
#### func Uint64P(key string, val *I) slog.Attr
#### func Uint64P(key string, val *I) slog.Attr
<span id="Uint64P"></span>
> 构造一个带有整数值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Float(key string, val F) slog.Attr
#### func Float(key string, val F) slog.Attr
<span id="Float"></span>
> 构造一个带有浮点值的字段
***
#### func FloatP(key string, val *F) slog.Attr
#### func FloatP(key string, val *F) slog.Attr
<span id="FloatP"></span>
> 构造一个带有浮点值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Float32(key string, val F) slog.Attr
#### func Float32(key string, val F) slog.Attr
<span id="Float32"></span>
> 构造一个带有浮点值的字段
***
#### func Float32P(key string, val *F) slog.Attr
#### func Float32P(key string, val *F) slog.Attr
<span id="Float32P"></span>
> 构造一个带有浮点值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Float64(key string, val F) slog.Attr
#### func Float64(key string, val F) slog.Attr
<span id="Float64"></span>
> 构造一个带有浮点值的字段
***
#### func Float64P(key string, val *F) slog.Attr
#### func Float64P(key string, val *F) slog.Attr
<span id="Float64P"></span>
> 构造一个带有浮点值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Time(key string, val time.Time) slog.Attr
#### func Time(key string, val time.Time) slog.Attr
<span id="Time"></span>
> 构造一个带有时间值的字段
***
#### func TimeP(key string, val *time.Time) slog.Attr
#### func TimeP(key string, val *time.Time) slog.Attr
<span id="TimeP"></span>
> 构造一个带有时间值的字段。返回的 Field 将在适当的时候安全且显式地表示 "null"
***
#### func Any(key string, val any) slog.Attr
#### func Any(key string, val any) slog.Attr
<span id="Any"></span>
> 构造一个带有任意值的字段
***
#### func Group(key string, args ...any) slog.Attr
#### func Group(key string, args ...any) slog.Attr
<span id="Group"></span>
> 返回分组字段
***
#### func Stack(key string) slog.Attr
#### func Stack(key string) slog.Attr
<span id="Stack"></span>
> 返回堆栈字段
@ -368,27 +368,27 @@ func TestStack(t *testing.T) {
***
#### func Err(err error) slog.Attr
#### func Err(err error) slog.Attr
<span id="Err"></span>
> 构造一个带有错误值的字段
***
#### func NewHandler(w io.Writer, opts *Options) slog.Handler
#### func NewHandler(w io.Writer, opts *Options) slog.Handler
<span id="NewHandler"></span>
> 创建一个更偏向于人类可读的处理程序,该处理程序也是默认的处理程序
***
#### func NewLogger(handlers ...slog.Handler) *Logger
#### func NewLogger(handlers ...slog.Handler) *Logger
<span id="NewLogger"></span>
> 创建一个新的日志记录器
***
#### func NewMultiHandler(handlers ...slog.Handler) slog.Handler
#### func NewMultiHandler(handlers ...slog.Handler) slog.Handler
<span id="NewMultiHandler"></span>
> 创建一个新的多处理程序
***
#### func NewOptions() *Options
#### func NewOptions() *Options
<span id="NewOptions"></span>
> 创建一个新的日志选项

View File

@ -45,13 +45,13 @@
***
## 详情信息
#### func NewFileFlusher(filePath string, layout ...string) *FileFlusher
#### func NewFileFlusher(filePath string, layout ...string) *FileFlusher
<span id="NewFileFlusher"></span>
> 创建一个文件刷新器
> - layout 为日志文件名的时间戳格式 (默认为 time.DateOnly)
***
#### func WithFlushInterval(interval time.Duration) Option
#### func WithFlushInterval(interval time.Duration) Option
<span id="WithFlushInterval"></span>
> 设置日志文件刷新间隔
> - 默认为 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
<span id="Analyze"></span>
> 分析特定文件的记录,当发生错误时,会发生 panic
> - handle 为并行执行的,需要自行处理并发安全
> - 适用于外部进程对于日志文件的读取,但是需要注意的是,此时日志文件可能正在被写入,所以可能会读取到错误的数据
***
#### func AnalyzeMulti(filePaths []string, handle func (analyzer *Analyzer, record R)) *Report
#### func AnalyzeMulti(filePaths []string, handle func (analyzer *Analyzer, record R)) *Report
<span id="AnalyzeMulti"></span>
> 与 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)
<span id="IncrementAnalyze"></span>
> 增量分析,返回一个函数,每次调用该函数都会分析文件中新增的内容

View File

@ -52,12 +52,12 @@
***
## 详情信息
#### func Compare(a V, expression CompareExpression, b V) bool
#### func Compare(a V, expression CompareExpression, b V) bool
<span id="Compare"></span>
> 根据特定表达式比较两个值
***
#### func IsContinuity(values S) bool
#### func IsContinuity(values S) bool
<span id="IsContinuity"></span>
> 检查一组值是否连续
@ -72,32 +72,32 @@ func ExampleIsContinuity() {
```
***
#### func IsContinuityWithSort(values S) bool
#### func IsContinuityWithSort(values S) bool
<span id="IsContinuityWithSort"></span>
> 检查一组值排序后是否连续
***
#### func GetDefaultTolerance() float64
#### func GetDefaultTolerance() float64
<span id="GetDefaultTolerance"></span>
> 获取默认误差范围
***
#### func Pow(a int, n int) int
#### func Pow(a int, n int) int
<span id="Pow"></span>
> 整数幂运算
***
#### func PowInt64(a int64, n int64) int64
#### func PowInt64(a int64, n int64) int64
<span id="PowInt64"></span>
> 整数幂运算
***
#### func Min(a V, b V) V
#### func Min(a V, b V) V
<span id="Min"></span>
> 返回两个数之中较小的值
***
#### func Max(a V, b V) V
#### func Max(a V, b V) V
<span id="Max"></span>
> 返回两个数之中较大的值
@ -112,17 +112,17 @@ func ExampleIsContinuity() {
> 将两个数按照较大的和较小的顺序进行返回
***
#### func Clamp(value V, min V, max V) V
#### func Clamp(value V, min V, max V) V
<span id="Clamp"></span>
> 将给定值限制在最小值和最大值之间
***
#### func Tolerance(value1 V, value2 V, tolerance V) bool
#### func Tolerance(value1 V, value2 V, tolerance V) bool
<span id="Tolerance"></span>
> 检查两个值是否在一个误差范围内
***
#### func Merge(refer V, a V, b V) V
#### func Merge(refer V, a V, b V) V
<span id="Merge"></span>
> 通过一个参考值合并两个数字
@ -132,17 +132,17 @@ func ExampleIsContinuity() {
> 通过一个参考值取消合并的两个数字
***
#### func MergeToInt64(v1 V, v2 V) int64
#### func MergeToInt64(v1 V, v2 V) int64
<span id="MergeToInt64"></span>
> 将两个数字合并为一个 int64 数字
***
#### func UnMergeInt64(n int64) V, V
#### func UnMergeInt64(n int64) (V, V)
<span id="UnMergeInt64"></span>
> 将一个 int64 数字拆分为两个数字
***
#### func ToContinuous(nums S) map[V]V
#### func ToContinuous(nums S) map[V]V
<span id="ToContinuous"></span>
> 将一组非连续的数字转换为从1开始的连续数字
> - 返回值是一个 mapkey 是从 1 开始的连续数字value 是原始数字
@ -160,34 +160,34 @@ func ExampleToContinuous() {
```
***
#### func CountDigits(num V) int
#### func CountDigits(num V) int
<span id="CountDigits"></span>
> 接收一个整数 num 作为输入,并返回该数字的位数
***
#### func GetDigitValue(num int64, digit int) int64
#### func GetDigitValue(num int64, digit int) int64
<span id="GetDigitValue"></span>
> 接收一个整数 num 和一个表示目标位数的整数 digit 作为输入,并返
> 回数字 num 在指定位数上的数值。我们使用 math.Abs() 函数获取 num 的绝对值,并通
> 过除以10的操作将 num 移动到目标位数上。然后,通过取余运算得到位数上的数值
***
#### func JoinNumbers(num1 V, n ...V) V
#### func JoinNumbers(num1 V, n ...V) V
<span id="JoinNumbers"></span>
> 将一组数字连接起来
***
#### func IsOdd(n V) bool
#### func IsOdd(n V) bool
<span id="IsOdd"></span>
> 返回 n 是否为奇数
***
#### func IsEven(n V) bool
#### func IsEven(n V) bool
<span id="IsEven"></span>
> 返回 n 是否为偶数
***
#### func MakeLastDigitsZero(num T, digits int) T
#### func MakeLastDigitsZero(num T, digits int) T
<span id="MakeLastDigitsZero"></span>
> 返回一个新的数,其中 num 的最后 digits 位数被设为零。
> - 函数首先创建一个 10 的 digits 次方的遮罩,然后通过整除和乘以这个遮罩来使 num 的最后 digits 位归零。

View File

@ -38,7 +38,7 @@
> 运行持久化缓存程序
***
#### func BindPersistCacheProgram(name string, handler OutputParamHandlerFunc, option ...*Option) func ()
#### func BindPersistCacheProgram(name string, handler OutputParamHandlerFunc, option ...*Option) func ()
<span id="BindPersistCacheProgram"></span>
> 绑定持久化缓存程序
> - name 持久化缓存程序名称
@ -52,7 +52,7 @@
> - 所有持久化程序绑定完成后,应该主动调用 Run 函数运行
***
#### func BindAction(name string, handler Func) Func
#### func BindAction(name string, handler Func) Func
<span id="BindAction"></span>
> 绑定需要缓存的操作函数
> - name 缓存操作名称
@ -92,7 +92,7 @@ func TestBindAction(t *testing.T) {
***
#### func NewOption() *Option
#### func NewOption() *Option
<span id="NewOption"></span>
***

View File

@ -37,7 +37,7 @@
***
## 详情信息
#### func NewTwoDimensional(options ...TwoDimensionalOption[EID, PosType]) *TwoDimensional[EID, PosType]
#### func NewTwoDimensional(options ...TwoDimensionalOption[EID, PosType]) *TwoDimensional[EID, PosType]
<span id="NewTwoDimensional"></span>
> 创建一个用于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]
<span id="WithTwoDimensionalTimeUnit"></span>
> 通过特定时间单位创建
> - 默认单位为1毫秒最小单位也为1毫秒
***
#### func WithTwoDimensionalIdleWaitTime(duration time.Duration) TwoDimensionalOption[EID, PosType]
#### func WithTwoDimensionalIdleWaitTime(duration time.Duration) TwoDimensionalOption[EID, PosType]
<span id="WithTwoDimensionalIdleWaitTime"></span>
> 通过特定的空闲等待时间创建
> - 默认情况下在没有新的移动计划时将限制 100毫秒 + 移动间隔事件(默认100毫秒)
***
#### func WithTwoDimensionalInterval(duration time.Duration) TwoDimensionalOption[EID, PosType]
#### func WithTwoDimensionalInterval(duration time.Duration) TwoDimensionalOption[EID, PosType]
<span id="WithTwoDimensionalInterval"></span>
> 通过特定的移动间隔时间创建
***
#### func NewEntity(guid int64, speed float64) *MoveEntity
#### func NewEntity(guid int64, speed float64) *MoveEntity
<span id="NewEntity"></span>
***

View File

@ -34,7 +34,7 @@
***
## 详情信息
#### func NewTime(offset time.Duration) *Time
#### func NewTime(offset time.Duration) *Time
<span id="NewTime"></span>
> 新建一个包含偏移的时间
@ -44,17 +44,17 @@
> 设置全局偏移时间
***
#### func GetGlobal() *Time
#### func GetGlobal() *Time
<span id="GetGlobal"></span>
> 获取全局偏移时间
***
#### func Now() time.Time
#### func Now() time.Time
<span id="Now"></span>
> 获取当前时间偏移后的时间
***
#### func Since(t time.Time) time.Duration
#### func Since(t time.Time) time.Duration
<span id="Since"></span>
> 获取当前时间偏移后的时间自从 t 以来经过的时间

View File

@ -52,69 +52,69 @@
***
## 详情信息
#### func Dice() int
#### func Dice() int
<span id="Dice"></span>
> 掷骰子
> - 常规掷骰子将返回 1-6 的随机数
***
#### func DiceN(n int) int
#### func DiceN(n int) int
<span id="DiceN"></span>
> 掷骰子
> - 与 Dice 不同的是,将返回 1-N 的随机数
***
#### func NetIP() net.IP
#### func NetIP() net.IP
<span id="NetIP"></span>
> 返回一个随机的IP地址
***
#### func Port() int
#### func Port() int
<span id="Port"></span>
> 返回一个随机的端口号
***
#### func IPv4() string
#### func IPv4() string
<span id="IPv4"></span>
> 返回一个随机产生的IPv4地址。
***
#### func IPv4Port() string
#### func IPv4Port() string
<span id="IPv4Port"></span>
> 返回一个随机产生的IPv4地址和端口。
***
#### func Int64(min int64, max int64) int64
#### func Int64(min int64, max int64) int64
<span id="Int64"></span>
> 返回一个介于min和max之间的int64类型的随机数。
***
#### func Int(min int, max int) int
#### func Int(min int, max int) int
<span id="Int"></span>
> 返回一个介于min和max之间的的int类型的随机数。
***
#### func Duration(min int64, max int64) time.Duration
#### func Duration(min int64, max int64) time.Duration
<span id="Duration"></span>
> 返回一个介于min和max之间的的Duration类型的随机数。
***
#### func Float64() float64
#### func Float64() float64
<span id="Float64"></span>
> 返回一个0~1的浮点数
***
#### func Float32() float32
#### func Float32() float32
<span id="Float32"></span>
> 返回一个0~1的浮点数
***
#### func IntN(n int) int
#### func IntN(n int) int
<span id="IntN"></span>
> 返回一个0~n的整数
***
#### func Bool() bool
#### func Bool() bool
<span id="Bool"></span>
> 返回一个随机的布尔值
@ -153,13 +153,13 @@ func TestProbabilitySlice(t *testing.T) {
> - 当总概率小于 1 将会发生未命中的情况
***
#### func Probability(p int, full ...int) bool
#### func Probability(p int, full ...int) bool
<span id="Probability"></span>
> 输入一个概率,返回是否命中
> - 当 full 不为空时,将以 full 为基数p 为分子,计算命中概率
***
#### func ProbabilityChooseOne(ps ...int) int
#### func ProbabilityChooseOne(ps ...int) int
<span id="ProbabilityChooseOne"></span>
> 输入一组概率,返回命中的索引
@ -168,39 +168,39 @@ func TestProbabilitySlice(t *testing.T) {
<span id="RefreshSeed"></span>
***
#### func ChineseName() string
#### func ChineseName() string
<span id="ChineseName"></span>
> 返回一个随机组成的中文姓名。
***
#### func EnglishName() string
#### func EnglishName() string
<span id="EnglishName"></span>
> 返回一个随机组成的英文姓名。
***
#### func Name() string
#### func Name() string
<span id="Name"></span>
> 返回一个随机组成的中文或英文姓名
> - 以1/2的概率决定生产的是中文还是英文姓名。
***
#### func NumberString(min int, max int) string
#### func NumberString(min int, max int) string
<span id="NumberString"></span>
> 返回一个介于min和max之间的string类型的随机数。
***
#### func NumberStringRepair(min int, max int) string
#### func NumberStringRepair(min int, max int) string
<span id="NumberStringRepair"></span>
> 返回一个介于min和max之间的string类型的随机数
> - 通过Int64生成一个随机数当结果的字符串长度小于max的字符串长度的情况下使用0在开头补齐。
***
#### func HostName() string
#### func HostName() string
<span id="HostName"></span>
> 返回一个随机产生的hostname。
***
#### func WeightSlice(getWeightHandle func (data T) int64, data ...T) T
#### func WeightSlice(getWeightHandle func (data T) int64, data ...T) T
<span id="WeightSlice"></span>
> 按权重随机从切片中产生一个数据并返回
@ -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
<span id="WeightMap"></span>
> 按权重随机从map中产生一个数据并返回

View File

@ -52,7 +52,7 @@
> 包装函数,后置函数执行后
***
#### func GetPtrUnExportFiled(s reflect.Value, filedIndex int) reflect.Value
#### func GetPtrUnExportFiled(s reflect.Value, filedIndex int) reflect.Value
<span id="GetPtrUnExportFiled"></span>
> 获取指针类型的未导出字段
@ -62,12 +62,12 @@
> 设置指针类型的未导出字段
***
#### func Copy(s reflect.Value) reflect.Value
#### func Copy(s reflect.Value) reflect.Value
<span id="Copy"></span>
> 拷贝
***
#### func GetPointer(src T) reflect.Value
#### func GetPointer(src T) reflect.Value
<span id="GetPointer"></span>
> 获取指针

View File

@ -29,27 +29,27 @@
***
## 详情信息
#### func GetWorkingDir() string
#### func GetWorkingDir() string
<span id="GetWorkingDir"></span>
> 获取工作目录绝对路径
***
#### func GetTempDir() string
#### func GetTempDir() string
<span id="GetTempDir"></span>
> 获取系统临时目录
***
#### func GetExecutablePathByBuild() string
#### func GetExecutablePathByBuild() string
<span id="GetExecutablePathByBuild"></span>
> 获取当前执行文件绝对路径go build
***
#### func GetExecutablePathByCaller() string
#### func GetExecutablePathByCaller() string
<span id="GetExecutablePathByCaller"></span>
> 获取当前执行文件绝对路径go run
***
#### func CurrentRunningFuncName(skip ...int) string
#### func CurrentRunningFuncName(skip ...int) string
<span id="CurrentRunningFuncName"></span>
> 获取正在运行的函数名

View File

@ -55,7 +55,7 @@
> 解除注销特定命名空间的唯一标识符
***
#### func Get() int64
#### func Get() int64
<span id="Get"></span>
> 获取全局唯一标识符
@ -65,7 +65,7 @@
> 重置全局唯一标识符
***
#### func GetWith(name any) int64
#### func GetWith(name any) int64
<span id="GetWith"></span>
> 获取特定命名空间的唯一标识符
@ -75,17 +75,17 @@
> 重置特定命名空间的唯一标识符
***
#### func NewOnce() *Once[V]
#### func NewOnce() *Once[V]
<span id="NewOnce"></span>
> 创建一个用于数据取值去重的结构实例
***
#### func SonyflakeIDE() int64, error
#### func SonyflakeIDE() (int64, error)
<span id="SonyflakeIDE"></span>
> 获取一个雪花id
***
#### func SonyflakeID() int64
#### func SonyflakeID() int64
<span id="SonyflakeID"></span>
> 获取一个雪花id
@ -95,32 +95,32 @@
> 配置雪花id生成策略
***
#### func AutoIncrementUint32() uint32
#### func AutoIncrementUint32() uint32
<span id="AutoIncrementUint32"></span>
> 获取一个自增的 uint32 值
***
#### func AutoIncrementUint64() uint64
#### func AutoIncrementUint64() uint64
<span id="AutoIncrementUint64"></span>
> 获取一个自增的 uint64 值
***
#### func AutoIncrementInt32() int32
#### func AutoIncrementInt32() int32
<span id="AutoIncrementInt32"></span>
> 获取一个自增的 int32 值
***
#### func AutoIncrementInt64() int64
#### func AutoIncrementInt64() int64
<span id="AutoIncrementInt64"></span>
> 获取一个自增的 int64 值
***
#### func AutoIncrementInt() int
#### func AutoIncrementInt() int
<span id="AutoIncrementInt"></span>
> 获取一个自增的 int 值
***
#### func AutoIncrementString() string
#### func AutoIncrementString() string
<span id="AutoIncrementString"></span>
> 获取一个自增的字符串

View File

@ -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)
<span id="Topological"></span>
> 拓扑排序是一种对有向图进行排序的算法,它可以用来解决一些依赖关系的问题,比如计算字段的依赖关系。拓扑排序会将存在依赖关系的元素进行排序,使得依赖关系的元素总是排在被依赖的元素之前。
> - slice: 需要排序的切片

View File

@ -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
<span id="RangeLine"></span>
> 对传入的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
<span id="SplitTrimSpace"></span>
> 按照空格分割字符串并去除空格
***
#### func FirstUpper(str string) string
#### func FirstUpper(str string) string
<span id="FirstUpper"></span>
> 首字母大写
***
#### func FirstLower(str string) string
#### func FirstLower(str string) string
<span id="FirstLower"></span>
> 首字母小写
***
#### func FirstUpperBytes(str []byte) []byte
#### func FirstUpperBytes(str []byte) []byte
<span id="FirstUpperBytes"></span>
> 首字母大写
***
#### func FirstLowerBytes(str []byte) []byte
#### func FirstLowerBytes(str []byte) []byte
<span id="FirstLowerBytes"></span>
> 首字母小写
***
#### func IsEmpty(str string) bool
#### func IsEmpty(str string) bool
<span id="IsEmpty"></span>
> 判断字符串是否为空
***
#### func IsEmptyBytes(str []byte) bool
#### func IsEmptyBytes(str []byte) bool
<span id="IsEmptyBytes"></span>
> 判断字符串是否为空
***
#### func IsNotEmpty(str string) bool
#### func IsNotEmpty(str string) bool
<span id="IsNotEmpty"></span>
> 判断字符串是否不为空
***
#### func IsNotEmptyBytes(str []byte) bool
#### func IsNotEmptyBytes(str []byte) bool
<span id="IsNotEmptyBytes"></span>
> 判断字符串是否不为空
***
#### func SnakeString(str string) string
#### func SnakeString(str string) string
<span id="SnakeString"></span>
> 蛇形字符串
***
#### func SnakeStringBytes(str []byte) []byte
#### func SnakeStringBytes(str []byte) []byte
<span id="SnakeStringBytes"></span>
> 蛇形字符串
***
#### func CamelString(str string) string
#### func CamelString(str string) string
<span id="CamelString"></span>
> 驼峰字符串
***
#### func CamelStringBytes(str []byte) []byte
#### func CamelStringBytes(str []byte) []byte
<span id="CamelStringBytes"></span>
> 驼峰字符串
***
#### func SortJoin(delimiter string, s ...string) string
#### func SortJoin(delimiter string, s ...string) string
<span id="SortJoin"></span>
> 将多个字符串排序后拼接
@ -130,19 +130,19 @@
> - 隐藏身份证、邮箱、手机号等敏感信息用*号替代
***
#### func ThousandsSeparator(str string) string
#### func ThousandsSeparator(str string) string
<span id="ThousandsSeparator"></span>
> 返回将str进行千位分隔符处理后的字符串。
***
#### func KV(str string, tag ...string) string, string
#### func KV(str string, tag ...string) (string, string)
<span id="KV"></span>
> 返回str经过转换后形成的key、value
> - 这里tag表示使用什么字符串来区分key和value的分隔符。
> - 默认情况即不传入tag的情况下分隔符为“=”。
***
#### func FormatSpeedyInt(numberStr string) int, error
#### func FormatSpeedyInt(numberStr string) (int, error)
<span id="FormatSpeedyInt"></span>
> 返回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)
<span id="FormatSpeedyInt64"></span>
> 返回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)
<span id="FormatSpeedyFloat32"></span>
> 返回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)
<span id="FormatSpeedyFloat64"></span>
> 返回numberStr经过格式化后去除空格和“,”分隔符的结果
> - 当字符串为“123,456,789.123”的时候返回结果为“123456789.123”。

View File

@ -104,12 +104,12 @@
***
## 详情信息
#### func NewBitSet(bits ...Bit) *BitSet[Bit]
#### func NewBitSet(bits ...Bit) *BitSet[Bit]
<span id="NewBitSet"></span>
> 通过指定的 Bit 位创建一个 BitSet
***
#### func TryWriteChannel(ch chan T, data T) bool
#### func TryWriteChannel(ch chan T, data T) bool
<span id="TryWriteChannel"></span>
> 尝试写入 channel如果 channel 无法写入则忽略,返回是否写入成功
> - 无法写入的情况包括channel 已满、channel 已关闭
@ -121,18 +121,18 @@
> - 无法写入的情况包括channel 已满、channel 已关闭
***
#### func RegError(code int, message string) error
#### func RegError(code int, message string) error
<span id="RegError"></span>
> 通过错误码注册错误,返回错误的引用
***
#### func RegErrorRef(code int, message string, ref error) error
#### func RegErrorRef(code int, message string, ref error) error
<span id="RegErrorRef"></span>
> 通过错误码注册错误,返回错误的引用
> - 引用将会被重定向到注册的错误信息
***
#### func GetError(err error) int, error
#### func GetError(err error) (int, error)
<span id="GetError"></span>
> 通过错误引用获取错误码和真实错误信息,如果错误不存在则返回 0如果错误引用不存在则返回原本的错误
@ -155,7 +155,7 @@ func TestGetError(t *testing.T) {
***
#### func RecoverTransform(a any) error
#### func RecoverTransform(a any) error
<span id="RecoverTransform"></span>
> recover 错误转换
@ -179,7 +179,7 @@ func ExampleRecoverTransform() {
> 执行 f 函数,如果 f 为 nil则不执行
***
#### func HandleErr(f func () error) error
#### func HandleErr(f func () error) error
<span id="HandleErr"></span>
> 执行 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
<span id="If"></span>
***
#### func MarshalJSON(v interface {}) []byte
#### func MarshalJSON(v interface {}) []byte
<span id="MarshalJSON"></span>
> 将对象转换为 json
> - 当转换失败时,将返回 json 格式的空对象
***
#### func MarshalJSONE(v interface {}) []byte, error
#### func MarshalJSONE(v interface {}) ([]byte, error)
<span id="MarshalJSONE"></span>
> 将对象转换为 json
> - 当转换失败时,将返回错误信息
***
#### func UnmarshalJSON(data []byte, v interface {}) error
#### func UnmarshalJSON(data []byte, v interface {}) error
<span id="UnmarshalJSON"></span>
> 将 json 转换为对象
***
#### func MarshalIndentJSON(v interface {}, prefix string, indent string) []byte
#### func MarshalIndentJSON(v interface {}, prefix string, indent string) []byte
<span id="MarshalIndentJSON"></span>
> 将对象转换为 json
***
#### func MarshalToTargetWithJSON(src interface {}, dest interface {}) error
#### func MarshalToTargetWithJSON(src interface {}, dest interface {}) error
<span id="MarshalToTargetWithJSON"></span>
> 将对象转换为目标对象
***
#### func StartLossCounter() *LossCounter
#### func StartLossCounter() *LossCounter
<span id="StartLossCounter"></span>
> 开始损耗计数
***
#### func Match(value Value) *Matcher[Value, Result]
#### func Match(value Value) *Matcher[Value, Result]
<span id="Match"></span>
> 匹配
@ -255,12 +255,12 @@ func TestMatch(t *testing.T) {
***
#### func IsNumber(v any) bool
#### func IsNumber(v any) bool
<span id="IsNumber"></span>
> 判断是否为数字
***
#### func NumberToRome(num int) string
#### func NumberToRome(num int) string
<span id="NumberToRome"></span>
> 将数字转换为罗马数字
@ -290,167 +290,167 @@ func TestNumberToRome(t *testing.T) {
***
#### func StringToInt(value string) int
#### func StringToInt(value string) int
<span id="StringToInt"></span>
> 字符串转换为整数
***
#### func StringToFloat64(value string) float64
#### func StringToFloat64(value string) float64
<span id="StringToFloat64"></span>
> 字符串转换为 float64
***
#### func StringToBool(value string) bool
#### func StringToBool(value string) bool
<span id="StringToBool"></span>
> 字符串转换为 bool
***
#### func StringToUint64(value string) uint64
#### func StringToUint64(value string) uint64
<span id="StringToUint64"></span>
> 字符串转换为 uint64
***
#### func StringToUint(value string) uint
#### func StringToUint(value string) uint
<span id="StringToUint"></span>
> 字符串转换为 uint
***
#### func StringToFloat32(value string) float32
#### func StringToFloat32(value string) float32
<span id="StringToFloat32"></span>
> 字符串转换为 float32
***
#### func StringToInt64(value string) int64
#### func StringToInt64(value string) int64
<span id="StringToInt64"></span>
> 字符串转换为 int64
***
#### func StringToUint32(value string) uint32
#### func StringToUint32(value string) uint32
<span id="StringToUint32"></span>
> 字符串转换为 uint32
***
#### func StringToInt32(value string) int32
#### func StringToInt32(value string) int32
<span id="StringToInt32"></span>
> 字符串转换为 int32
***
#### func StringToUint16(value string) uint16
#### func StringToUint16(value string) uint16
<span id="StringToUint16"></span>
> 字符串转换为 uint16
***
#### func StringToInt16(value string) int16
#### func StringToInt16(value string) int16
<span id="StringToInt16"></span>
> 字符串转换为 int16
***
#### func StringToUint8(value string) uint8
#### func StringToUint8(value string) uint8
<span id="StringToUint8"></span>
> 字符串转换为 uint8
***
#### func StringToInt8(value string) int8
#### func StringToInt8(value string) int8
<span id="StringToInt8"></span>
> 字符串转换为 int8
***
#### func StringToByte(value string) byte
#### func StringToByte(value string) byte
<span id="StringToByte"></span>
> 字符串转换为 byte
***
#### func StringToRune(value string) rune
#### func StringToRune(value string) rune
<span id="StringToRune"></span>
> 字符串转换为 rune
***
#### func IntToString(value int) string
#### func IntToString(value int) string
<span id="IntToString"></span>
> 整数转换为字符串
***
#### func Float64ToString(value float64) string
#### func Float64ToString(value float64) string
<span id="Float64ToString"></span>
> float64 转换为字符串
***
#### func BoolToString(value bool) string
#### func BoolToString(value bool) string
<span id="BoolToString"></span>
> bool 转换为字符串
***
#### func Uint64ToString(value uint64) string
#### func Uint64ToString(value uint64) string
<span id="Uint64ToString"></span>
> uint64 转换为字符串
***
#### func UintToString(value uint) string
#### func UintToString(value uint) string
<span id="UintToString"></span>
> uint 转换为字符串
***
#### func Float32ToString(value float32) string
#### func Float32ToString(value float32) string
<span id="Float32ToString"></span>
> float32 转换为字符串
***
#### func Int64ToString(value int64) string
#### func Int64ToString(value int64) string
<span id="Int64ToString"></span>
> int64 转换为字符串
***
#### func Uint32ToString(value uint32) string
#### func Uint32ToString(value uint32) string
<span id="Uint32ToString"></span>
> uint32 转换为字符串
***
#### func Int32ToString(value int32) string
#### func Int32ToString(value int32) string
<span id="Int32ToString"></span>
> int32 转换为字符串
***
#### func Uint16ToString(value uint16) string
#### func Uint16ToString(value uint16) string
<span id="Uint16ToString"></span>
> uint16 转换为字符串
***
#### func Int16ToString(value int16) string
#### func Int16ToString(value int16) string
<span id="Int16ToString"></span>
> int16 转换为字符串
***
#### func Uint8ToString(value uint8) string
#### func Uint8ToString(value uint8) string
<span id="Uint8ToString"></span>
> uint8 转换为字符串
***
#### func Int8ToString(value int8) string
#### func Int8ToString(value int8) string
<span id="Int8ToString"></span>
> int8 转换为字符串
***
#### func ByteToString(value byte) string
#### func ByteToString(value byte) string
<span id="ByteToString"></span>
> byte 转换为字符串
***
#### func RuneToString(value rune) string
#### func RuneToString(value rune) string
<span id="RuneToString"></span>
> rune 转换为字符串
***
#### func StringToSlice(value string) []string
#### func StringToSlice(value string) []string
<span id="StringToSlice"></span>
> 字符串转换为切片
***
#### func SliceToString(value []string) string
#### func SliceToString(value []string) string
<span id="SliceToString"></span>
> 切片转换为字符串
***
#### func NewPermission() *Permission[Code, EntityID]
#### func NewPermission() *Permission[Code, EntityID]
<span id="NewPermission"></span>
> 创建权限
@ -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
<span id="Retry"></span>
> 根据提供的 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
<span id="RetryByRule"></span>
> 根据提供的规则尝试执行 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
<span id="RetryByExponentialBackoff"></span>
> 根据指数退避算法尝试执行 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
<span id="ConditionalRetryByExponentialBackoff"></span>
> 该函数与 RetryByExponentialBackoff 类似,但是可以被中断
> - cond 为中断条件,当 cond 返回 false 时,将会中断重试
@ -532,37 +532,37 @@ func TestNewPermission(t *testing.T) {
> 根据提供的 interval 时间间隔尝试执行 f 函数,如果 f 函数返回错误,则在 interval 后重试,直到成功
***
#### func NewStackGo() *StackGo
#### func NewStackGo() *StackGo
<span id="NewStackGo"></span>
> 返回一个用于获取上一个协程调用的堆栈信息的收集器
***
#### func LaunchTime() time.Time
#### func LaunchTime() time.Time
<span id="LaunchTime"></span>
> 获取程序启动时间
***
#### func Hostname() string
#### func Hostname() string
<span id="Hostname"></span>
> 获取主机名
***
#### func PID() int
#### func PID() int
<span id="PID"></span>
> 获取进程 PID
***
#### func StringToBytes(s string) []byte
#### func StringToBytes(s string) []byte
<span id="StringToBytes"></span>
> 以零拷贝的方式将字符串转换为字节切片
***
#### func BytesToString(b []byte) string
#### func BytesToString(b []byte) string
<span id="BytesToString"></span>
> 以零拷贝的方式将字节切片转换为字符串
***
#### func Convert(src A) B
#### func Convert(src A) B
<span id="Convert"></span>
> 以零拷贝的方式将一个对象转换为另一个对象
> - 两个对象字段必须完全一致
@ -591,7 +591,7 @@ func TestConvert(t *testing.T) {
***
#### func Verify(handle func ( V)) *VerifyHandle[V]
#### func Verify(handle func ( V)) *VerifyHandle[V]
<span id="Verify"></span>
> 对特定表达式进行校验,当表达式不成立时,将执行 handle
@ -618,7 +618,7 @@ func ExampleVerify() {
```
***
#### func OldVersion(version1 string, version2 string) bool
#### func OldVersion(version1 string, version2 string) bool
<span id="OldVersion"></span>
> 检查 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
<span id="CompareVersion"></span>
> 返回一个整数,用于表示两个版本号的比较结果:
> - 如果 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

View File

@ -66,17 +66,17 @@
> 偏移时间新的一天事件
***
#### func WithCaller(handle func (name string, caller func ())) Option
#### func WithCaller(handle func (name string, caller func ())) Option
<span id="WithCaller"></span>
> 通过其他的 handle 执行 Caller
***
#### func WithMark(mark string) Option
#### func WithMark(mark string) Option
<span id="WithMark"></span>
> 通过特定的标记创建定时器
***
#### func NewPool(tickerPoolSize int) *Pool
#### func NewPool(tickerPoolSize int) *Pool
<span id="NewPool"></span>
> 创建一个定时器池,当 tickerPoolSize 小于等于 0 时,将会引发 panic可指定为 DefaultTickerPoolSize
@ -87,7 +87,7 @@
> - 默认值为 DefaultTickerPoolSize当定时器池中的定时器不足时会自动创建新的定时器当定时器释放时会将多余的定时器进行释放否则将放入定时器池中
***
#### func GetTicker(size int, options ...Option) *Ticker
#### func GetTicker(size int, options ...Option) *Ticker
<span id="GetTicker"></span>
> 获取标准池中的一个定时器

View File

@ -78,12 +78,12 @@
***
## 详情信息
#### func CalcNextSec(sec int) int
#### func CalcNextSec(sec int) int
<span id="CalcNextSec"></span>
> 计算下一个N秒在多少秒之后
***
#### func CalcNextSecWithTime(t time.Time, sec int) int
#### func CalcNextSecWithTime(t time.Time, sec int) int
<span id="CalcNextSecWithTime"></span>
> 计算下一个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
<span id="CalcNextTimeWithRefer"></span>
> 根据参考时间计算下一个整点时间
> - 假设当 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
<span id="IntervalFormat"></span>
> 返回指定时间戳之间的间隔
> - 使用传入的时间进行计算换算,将结果体现为几年前、几天前、几小时前、几分钟前、几秒前。
***
#### func GetMonthDays(t time.Time) int
#### func GetMonthDays(t time.Time) int
<span id="GetMonthDays"></span>
> 获取一个时间当月共有多少天
***
#### func WeekDay(t time.Time) int
#### func WeekDay(t time.Time) int
<span id="WeekDay"></span>
> 获取一个时间是星期几
> - 1 ~ 7
***
#### func GetNextDayInterval(t time.Time) time.Duration
#### func GetNextDayInterval(t time.Time) time.Duration
<span id="GetNextDayInterval"></span>
> 获取一个时间到下一天间隔多少秒
***
#### func GetToday(t time.Time) time.Time
#### func GetToday(t time.Time) time.Time
<span id="GetToday"></span>
> 获取一个时间的今天
***
#### func GetSecond(d time.Duration) int
#### func GetSecond(d time.Duration) int
<span id="GetSecond"></span>
> 获取共有多少秒
***
#### func IsSameDay(t1 time.Time, t2 time.Time) bool
#### func IsSameDay(t1 time.Time, t2 time.Time) bool
<span id="IsSameDay"></span>
> 两个时间是否是同一天
***
#### func IsSameHour(t1 time.Time, t2 time.Time) bool
#### func IsSameHour(t1 time.Time, t2 time.Time) bool
<span id="IsSameHour"></span>
> 两个时间是否是同一小时
***
#### func GetMondayZero(t time.Time) time.Time
#### func GetMondayZero(t time.Time) time.Time
<span id="GetMondayZero"></span>
> 获取本周一零点
***
#### func Date(year int, month time.Month, day int) time.Time
#### func Date(year int, month time.Month, day int) time.Time
<span id="Date"></span>
> 返回一个特定日期的时间
***
#### 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
<span id="DateWithHMS"></span>
> 返回一个精确到秒的时间
***
#### func GetDeltaDay(t1 time.Time, t2 time.Time) int
#### func GetDeltaDay(t1 time.Time, t2 time.Time) int
<span id="GetDeltaDay"></span>
> 获取两个时间需要加减的天数
***
#### func GetDeltaWeek(t1 time.Time, t2 time.Time) int
#### func GetDeltaWeek(t1 time.Time, t2 time.Time) int
<span id="GetDeltaWeek"></span>
> 获取两个时间需要加减的周数
@ -184,73 +184,73 @@ func ExampleCalcNextSecWithTime() {
> 从时间字符串中获取时分秒
***
#### func GetTimeFromString(timeStr string, layout string) time.Time
#### func GetTimeFromString(timeStr string, layout string) time.Time
<span id="GetTimeFromString"></span>
> 将时间字符串转化为时间
***
#### func GetDayZero(t time.Time, day int) time.Time
#### func GetDayZero(t time.Time, day int) time.Time
<span id="GetDayZero"></span>
> 获取 t 增加 day 天后的零点时间
***
#### func GetYesterday(t time.Time) time.Time
#### func GetYesterday(t time.Time) time.Time
<span id="GetYesterday"></span>
> 获取昨天
***
#### func GetDayLast(t time.Time) time.Time
#### func GetDayLast(t time.Time) time.Time
<span id="GetDayLast"></span>
> 获取某天的最后一刻
> - 最后一刻即 23:59:59
***
#### func GetYesterdayLast(t time.Time) time.Time
#### func GetYesterdayLast(t time.Time) time.Time
<span id="GetYesterdayLast"></span>
> 获取昨天最后一刻
***
#### func GetMinuteStart(t time.Time) time.Time
#### func GetMinuteStart(t time.Time) time.Time
<span id="GetMinuteStart"></span>
> 获取一个时间的 0 秒
***
#### func GetMinuteEnd(t time.Time) time.Time
#### func GetMinuteEnd(t time.Time) time.Time
<span id="GetMinuteEnd"></span>
> 获取一个时间的 59 秒
***
#### func GetHourStart(t time.Time) time.Time
#### func GetHourStart(t time.Time) time.Time
<span id="GetHourStart"></span>
> 获取一个时间的 0 分 0 秒
***
#### func GetHourEnd(t time.Time) time.Time
#### func GetHourEnd(t time.Time) time.Time
<span id="GetHourEnd"></span>
> 获取一个时间的 59 分 59 秒
***
#### func GetMonthStart(t time.Time) time.Time
#### func GetMonthStart(t time.Time) time.Time
<span id="GetMonthStart"></span>
> 获取一个时间的月初
***
#### func GetMonthEnd(t time.Time) time.Time
#### func GetMonthEnd(t time.Time) time.Time
<span id="GetMonthEnd"></span>
> 获取一个时间的月末
***
#### func GetYearStart(t time.Time) time.Time
#### func GetYearStart(t time.Time) time.Time
<span id="GetYearStart"></span>
> 获取一个时间的年初
***
#### func GetYearEnd(t time.Time) time.Time
#### func GetYearEnd(t time.Time) time.Time
<span id="GetYearEnd"></span>
> 获取一个时间的年末
***
#### func NewStateLine(zero State) *StateLine[State]
#### func NewStateLine(zero State) *StateLine[State]
<span id="NewStateLine"></span>
> 创建一个从左向右由早到晚的状态时间线
@ -304,12 +304,12 @@ func TestSetGlobalTimeOffset(t *testing.T) {
***
#### func NowByNotOffset() time.Time
#### func NowByNotOffset() time.Time
<span id="NowByNotOffset"></span>
> 获取未偏移的当前时间
***
#### func GetGlobalTimeOffset() time.Duration
#### func GetGlobalTimeOffset() time.Duration
<span id="GetGlobalTimeOffset"></span>
> 获取全局时间偏移量
@ -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
<span id="NewPeriod"></span>
> 创建一个时间段
> - 如果 start 比 end 晚,则会自动交换两个时间
***
#### func NewPeriodWindow(t time.Time, size time.Duration) Period
#### func NewPeriodWindow(t time.Time, size time.Duration) Period
<span id="NewPeriodWindow"></span>
> 创建一个特定长度的时间窗口
@ -349,52 +349,52 @@ func TestNewPeriodWindow(t *testing.T) {
***
#### func NewPeriodWindowWeek(t time.Time) Period
#### func NewPeriodWindowWeek(t time.Time) Period
<span id="NewPeriodWindowWeek"></span>
> 创建一周长度的时间窗口,从周一零点开始至周日 23:59:59 结束
***
#### func NewPeriodWithTimeArray(times [2]time.Time) Period
#### func NewPeriodWithTimeArray(times [2]time.Time) Period
<span id="NewPeriodWithTimeArray"></span>
> 创建一个时间段
***
#### func NewPeriodWithDayZero(t time.Time, day int) Period
#### func NewPeriodWithDayZero(t time.Time, day int) Period
<span id="NewPeriodWithDayZero"></span>
> 创建一个时间段,从 t 开始,持续到 day 天后的 0 点
***
#### func NewPeriodWithDay(t time.Time, day int) Period
#### func NewPeriodWithDay(t time.Time, day int) Period
<span id="NewPeriodWithDay"></span>
> 创建一个时间段,从 t 开始,持续 day 天
***
#### func NewPeriodWithHour(t time.Time, hour int) Period
#### func NewPeriodWithHour(t time.Time, hour int) Period
<span id="NewPeriodWithHour"></span>
> 创建一个时间段,从 t 开始,持续 hour 小时
***
#### func NewPeriodWithMinute(t time.Time, minute int) Period
#### func NewPeriodWithMinute(t time.Time, minute int) Period
<span id="NewPeriodWithMinute"></span>
> 创建一个时间段,从 t 开始,持续 minute 分钟
***
#### func NewPeriodWithSecond(t time.Time, second int) Period
#### func NewPeriodWithSecond(t time.Time, second int) Period
<span id="NewPeriodWithSecond"></span>
> 创建一个时间段,从 t 开始,持续 second 秒
***
#### func NewPeriodWithMillisecond(t time.Time, millisecond int) Period
#### func NewPeriodWithMillisecond(t time.Time, millisecond int) Period
<span id="NewPeriodWithMillisecond"></span>
> 创建一个时间段,从 t 开始,持续 millisecond 毫秒
***
#### func NewPeriodWithMicrosecond(t time.Time, microsecond int) Period
#### func NewPeriodWithMicrosecond(t time.Time, microsecond int) Period
<span id="NewPeriodWithMicrosecond"></span>
> 创建一个时间段,从 t 开始,持续 microsecond 微秒
***
#### func NewPeriodWithNanosecond(t time.Time, nanosecond int) Period
#### func NewPeriodWithNanosecond(t time.Time, nanosecond int) Period
<span id="NewPeriodWithNanosecond"></span>
> 创建一个时间段,从 t 开始,持续 nanosecond 纳秒

View File

@ -25,7 +25,7 @@
***
## 详情信息
#### func GetSheetMatrix(sheet *xlsx.Sheet) *matrix.Matrix[*xlsx.Cell]
#### func GetSheetMatrix(sheet *xlsx.Sheet) *matrix.Matrix[*xlsx.Cell]
<span id="GetSheetMatrix"></span>
> 将sheet转换为二维矩阵