This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package Test
import (
"fmt"
"github.com/holdno/snowFlakeByGo"
"testing"
)
func TestSnowFlake(t *testing.T) {
var IdWorker *snowFlakeByGo.Worker
var IdWorker2 *snowFlakeByGo.Worker
// 生成一个节点实例
// 传入当前节点id 此id在机器集群中一定要唯一 且从0开始排最多1024个节点,
//可以根据节点的不同动态调整该算法每毫秒生成的id上限(如何调整会在后面讲到)
IdWorker, _ = snowFlakeByGo.NewWorker(0)
IdWorker2, _ = snowFlakeByGo.NewWorker(1)
// 获得唯一id
id := IdWorker.GetId()
// 就是这么easy...
fmt.Println(id)
id = IdWorker.GetId()
id = IdWorker2.GetId()
}