genstr

package
v1.10.5 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: MulanPSL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StrGen strGen
View Source
var UUIDGen uuidGen

Functions

This section is empty.

Types

type Nano added in v1.9.18

type Nano struct {
	Alphabet string
	Size     int
}

func DefaultNano added in v1.9.18

func DefaultNano() *Nano

func (*Nano) Generate added in v1.9.18

func (nano *Nano) Generate() (string, error)

Generate is a low-level function to change alphabet and ID size.

func (*Nano) Must added in v1.9.18

func (nano *Nano) Must(l ...int) string

Must is the same as New but panics on error.

func (*Nano) MustGenerate added in v1.9.18

func (nano *Nano) MustGenerate() string

MustGenerate is the same as Generate but panics on error.

func (*Nano) New added in v1.9.18

func (nano *Nano) New(l ...int) (string, error)

New generates secure URL-friendly unique ID. Accepts optional parameter - length of the ID to be generated (21 by default).

type UUID

type UUID [16]byte

UUID type.

func (UUID) Hex

func (this UUID) Hex() string

Hex returns a hex string representation of the UUID in xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.

func (UUID) String

func (this UUID) String() string

type Worker

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

定义一个woker工作节点所需要的基本参数

var Snowflake *Worker

func NewWorker

func NewWorker(workerId int64) (*Worker, error)

实例化一个工作节点 workerId 为当前节点的id

func RandomWorker

func RandomWorker() *Worker

func (*Worker) ConvToShort62

func (w *Worker) ConvToShort62(id int64) (output string)

func (*Worker) GetId

func (w *Worker) GetId() int64

生成方法一定要挂载在某个woker下,这样逻辑会比较清晰 指定某个节点生成id

func (*Worker) GetString

func (w *Worker) GetString() string

func (*Worker) GetStringHex

func (w *Worker) GetStringHex() string

func (*Worker) GetStringHexTrim

func (w *Worker) GetStringHexTrim() string

func (*Worker) Short62

func (w *Worker) Short62() (output string)

func (*Worker) WorkerId

func (w *Worker) WorkerId() int64

Jump to

Keyboard shortcuts

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