generator

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SnowflakeGenerator = GeneratorType(1)
	SnoyflakeGenerator = GeneratorType(2)
)
View Source
const (
	ElemLowerCharAndNum = StringElem(1)
	ElemUpperCharAndNum = StringElem(2)
	ElemAllChar         = StringElem(3)
)

Variables

View Source
var (
	Snowflake *snowflakeGenerator

	ErrNodeOverflow = errors.New("machine bit overflow")
	ErrNodeNotSetup = errors.New("node has not been setup")
)
View Source
var (
	Snoyflake *snoyflakeGenerator

	ErrInvalidIPFormat = errors.New("ip format error")
)

Functions

func GenOpenId

func GenOpenId() string

* Gen Open ID

func GenRandString

func GenRandString(length int, elem StringElem) (code string)

* Gen Rand String

func GenSerialNo

func GenSerialNo(prefix string, suffix string) string

* Gen Serial No

func GenUUIDv1 added in v0.0.7

func GenUUIDv1() (id string, err error)

func GenUUIDv4 added in v0.0.7

func GenUUIDv4() (id string, err error)

func SetupGenerator added in v0.0.7

func SetupGenerator(generator GeneratorType, machine string) error

Types

type GeneratorType added in v0.0.7

type GeneratorType uint8

type IGenerator added in v0.0.7

type IGenerator interface {
	GenID() (int64, error)
}

type StringElem

type StringElem int

Jump to

Keyboard shortcuts

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