Categorygithub.com/Golang-Tools/idgener
modulepackage
0.0.4
Repository: https://github.com/golang-tools/idgener.git
Documentation: pkg.go.dev

# README

idgener

用于生成随机不(难以)重复id的函数.

目前支持3种算法

  • uuid4
  • sonyflake
  • snowflake

用法

  • 使用默认生成器--调用func Next(idgen_name string) (string, error)

  • 创建生成器--调用func IDGenNameToIDGen(idgen_name string) (IDGenInterface, error)

# Packages

用于获取MachineID,MachineID指当前机器的id,使用机器第一张网卡的可用ip地址构造 提供全局变量 `MachineIDStr string`用于保存MachineID的字符串形式 `MachineID uint16`用于保存MachineID原始的整型数形式 这两个全局变量都会在模块初始化时计算获得,不需要额外调用函数获得.

# Functions

IDGenNameToIDGen 通过名字获得一个IDGen实例 @params idgen_name string idgen的名字,目前支持uuid4,sonyflake,snowflake.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Next 使用默认id生成器构造id @params idgen_name string idgen的名字,目前支持uuid4,sonyflake,snowflake.
WithCheckMachineID 设置校验机器id的函数.
WithMachineID 设置机器id.
WithNodeID 设置节点id.
WithStartTime 设置起始时间.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
AckModeAckWhenGet 获取到后确认.

# Variables

DefaultSnowflake 默认snowflake生成器,nodeid为本机MachineID.
No description provided by the author
DefaultSonyflake 默认的sonyflake生成器,使用本机MachineID作为MachineID.
No description provided by the author
DefaultULID 默认的ulid生成器.
DefaultUUID4 默认uuid4id生成器.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

IDGenInterface 满足该接口的就认为是IDGen.

# Type aliases

No description provided by the author