idgen

package module
v0.0.61 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: MIT Imports: 4 Imported by: 2

Documentation

Overview

Package idgen provides the helpers functions.

Index

Constants

This section is empty.

Variables

View Source
var StartNumber = int64(rand.Int32()) << 32

StartNumber is the start number of the randNumber.

Functions

func GenID

func GenID() string

GenID The function "GenID" generates a new unique identifier and returns it as a string.

func Register

func Register(identifier Identifier)

Register sets the defaultIdentifier randNumber.

func Size

func Size() int

Size The function "Size" returns the size of the generated identifier

func Validate

func Validate(id string) bool

Validate The function "Validate" checks whether the given identifier is valid or not.

Types

type Identifier

type Identifier interface {
	Name() string
	Gen() string
	Validate(id string) bool
	Size() int
}

Identifier is the interface of randNumber.

func Default

func Default() Identifier

Default method returns the default defaultGenerator randNumber.

func NewNumber

func NewNumber(sta int64) Identifier

NewNumber method creates a new instance of the randNumber type.

Directories

Path Synopsis
Package snowflake provides a unique ID generation based on Twitter Snowflake algorithm.
Package snowflake provides a unique ID generation based on Twitter Snowflake algorithm.
Package ulid provides a ULID (Universally Unique Lexicographically Sortable Identifier) implementation.
Package ulid provides a ULID (Universally Unique Lexicographically Sortable Identifier) implementation.
Package uuid provides a UUID (Universally Unique Identifier) implementation.
Package uuid provides a UUID (Universally Unique Identifier) implementation.
Package xid provides a unique identifier generator based on xid.
Package xid provides a unique identifier generator based on xid.

Jump to

Keyboard shortcuts

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