guid

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2021 License: MIT Imports: 9 Imported by: 0

README

guid

介绍

golang uid 生成器

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
码云特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. 码云官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解码云上的优秀开源项目
  4. GVP 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目
  5. 码云官方提供的使用手册 https://gitee.com/help
  6. 码云封面人物是一档用来展示码云会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

View Source
const (
	WorkerIdBits = 10 // Num of WorkerId Bits
	SequenceBits = 12 // Num of Sequence Bits

	WorkerIdShift  = 12
	TimeStampShift = 22
)

Variables

View Source
var (
	MaxWorker    = maxInt(WorkerIdBits)
	SequenceMask = maxInt(SequenceBits)
)

Functions

func GenId

func GenId(t time.Time, ts int64, workerId int64, seq int64) (id int64)

func GetProjectStartTime

func GetProjectStartTime() (t time.Time)

func InitWithDB

func InitWithDB(dbType DBType, dsn string) (err error)

func ParseId

func ParseId(id int64) (t time.Time, ts int64, workerId int64, seq int64)

func SetProjectStartTime

func SetProjectStartTime(t time.Time)

Types

type DBType

type DBType int
const (
	DBTypePG DBType
	DBTypeMysql
)

type IdWorker

type IdWorker struct {
	// contains filtered or unexported fields
}

IdWorker Struct

func NewIdWorker

func NewIdWorker(workerId int64) (iw *IdWorker, err error)

NewIdWorker Func: Generate NewIdWorker with Given workerid

func NewWorker

func NewWorker() (iw *IdWorker)

func (*IdWorker) NextId

func (iw *IdWorker) NextId() (ts int64, err error)

Generate next id

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL