nuid – github.com/nats-io/nuid Index | Files

package nuid

import "github.com/nats-io/nuid"

A unique identifier generator that is high performance, very fast, and tries to be entropy pool friendly.

Index

Constants

const Version = "1.0.1"

Version of the library

Functions

func Next

func Next() string

Generate the next NUID string from the global locked NUID instance.

Types

type NUID

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

func New

func New() *NUID

New will generate a new NUID and properly initialize the prefix, sequential start, and sequential increment.

func (*NUID) Next

func (n *NUID) Next() string

Generate the next NUID string.

func (*NUID) RandomizePrefix

func (n *NUID) RandomizePrefix()

Generate a new prefix from crypto/rand. This call *can* drain entropy and will be called automatically when we exhaust the sequential range. Will panic if it gets an error from rand.Int()

Source Files

nuid.go

Version
v1.0.1 (latest)
Published
Apr 10, 2019
Platform
js/wasm
Imports
7 packages
Last checked
now

Tools for package owners.