From 9c450415a29010b4411d494f2aa53baf94d8cda0 Mon Sep 17 00:00:00 2001 From: Bobo Date: Wed, 4 Jun 2025 22:17:05 +0800 Subject: [PATCH] feat: id utils --- id/snowflake.go | 5 +++++ id/sonyflake.go | 5 +++++ tag.bat | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/id/snowflake.go b/id/snowflake.go index 32007e8..d59f9b8 100644 --- a/id/snowflake.go +++ b/id/snowflake.go @@ -59,3 +59,8 @@ func NewSnowflakeID(workerId int64) (int64, error) { return node.Generate(), nil } + +func GenerateSnowflakeID(workerId int64) int64 { + id, _ := NewSnowflakeID(workerId) + return id +} diff --git a/id/sonyflake.go b/id/sonyflake.go index 18a675c..4941a86 100644 --- a/id/sonyflake.go +++ b/id/sonyflake.go @@ -23,3 +23,8 @@ func NewSonyflakeID() (uint64, error) { return sf.NextID() } + +func GenerateSonyflakeID() uint64 { + id, _ := NewSonyflakeID() + return id +} diff --git a/tag.bat b/tag.bat index f6aaba5..f018f25 100644 --- a/tag.bat +++ b/tag.bat @@ -5,7 +5,7 @@ git tag geoip/v1.1.5 git tag translator/v1.1.2 git tag copierutil/v0.0.5 git tag jwtutil/v0.0.2 -git tag id/v0.0.1 +git tag id/v0.0.2 git tag slug/v0.0.1 git tag entgo/v1.1.30