Skip to content

FAWC438/uid-generator-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Uid-Generator-GO

A Go version of Uid-Generator , a Snowflake based unique ID generator.

Status

Work in progress.

  • BaseGenerator(DefaultGenerator)
  • CachedGenerator

Welcome to open issues or pull requests to help me complete this project.

Difference

All code logic is the same as the Java version, but the following differences:

  • WorkerIDAssigner is not implemented, so you need to assign worker id by yourself.
  • Difference between Goroutines and Java Threads
  • ...

Usage

import "github.com/FAWC438/uid-generator-go"

...

There is a demo to show how to use BaseGenerator.

package test

import (
	"fmt"
	"uid-generator-go/generator"
)

func Test() {
	var gen generator.UidGenerator
	gen = generator.BaseGeneratorConstructor()

	uid, e := gen.GetUID()
	if e != nil {
		fmt.Println(e)
		return
	}
	fmt.Println(gen.ParseUID(uid))
}

Run this test and get your first awesome uid!

About

A Go version of baidu/uid-generator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages