nid

package
v3.1.19 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Alphabet = "abcdefghijklmnopqrstuvwxyz0123456789"
	Size     = 6
	MaxValue = 36 * 36 * 36 * 36 * 36 * 36
)

Variables

View Source
var (
	ErrExhausted        = errors.New("nid exhausted")
	ErrInvalidLength    = errors.New("invalid nid length")
	ErrInvalidCharacter = errors.New("invalid nid character")
	ErrOutOfRange       = errors.New("nid out of range")

	Default = New()
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Start ID
}

type Generator

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

func New

func New(config ...Config) *Generator

func (*Generator) Generate

func (g *Generator) Generate() (ID, error)

func (*Generator) MustGenerate

func (g *Generator) MustGenerate() ID

func (*Generator) Reserve

func (g *Generator) Reserve(id ID) bool

type ID

type ID int64

func Decode

func Decode(s string) (ID, error)

func Generate

func Generate() (ID, error)

func MustGenerate

func MustGenerate() ID

func ParseString

func ParseString(s string) (ID, error)

func (ID) Encode

func (id ID) Encode() string

func (ID) GormDBDataType

func (ID) GormDBDataType(db *gorm.DB, field *schema.Field) string

func (ID) GormValue

func (id ID) GormValue(ctx context.Context, db *gorm.DB) clause.Expr

func (ID) Int64

func (id ID) Int64() int64

func (ID) IsValid

func (id ID) IsValid() bool

func (ID) IsZero

func (id ID) IsZero() bool

func (ID) MarshalBinary

func (id ID) MarshalBinary() ([]byte, error)

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

func (*ID) Scan

func (id *ID) Scan(value any) error

func (ID) String

func (id ID) String() string

func (*ID) UnmarshalBinary

func (id *ID) UnmarshalBinary(data []byte) error

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(data []byte) error

func (ID) Value

func (id ID) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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