shortid

package
v3.1.18 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(s string) (int64, error)

Basebase Decode

func Encode

func Encode(n int64) string

Base62 Encode

Types

type Config

type Config struct {
	NodeID      int64
	CounterBits uint8
	EpochMS     int64
	Salt        int64
}

Config 配置

type Generator

type Generator struct {
	// contains filtered or unexported fields
}
var (
	Default *Generator
)

func NewGenerator

func NewGenerator(cfg *Config) *Generator

新建生成器

func (*Generator) Decode

func (g *Generator) Decode(s string) (int64, error)

Decode 将 Base62 转回原始 int64

func (*Generator) Next

func (g *Generator) Next() string

Next 返回 8位 Base62

func (*Generator) NextID

func (g *Generator) NextID() int64

生成原始 int64 ID

Jump to

Keyboard shortcuts

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