fastuuid

package module
v0.0.0-...-6724a57 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2015 License: BSD-3-Clause Imports: 4 Imported by: 222

README

fastuuid

-- import "github.com/rogpeppe/fastuuid"

Package fastuuid provides fast UUID generation of 192 bit universally unique identifiers. It does not provide formatting or parsing of the identifiers (it is assumed that a simple hexadecimal or base64 representation is sufficient, for which adequate functionality exists elsewhere).

Note that the generated UUIDs are not unguessable - each UUID generated from a Generator is adjacent to the previously generated UUID.

It ignores RFC 4122.

Usage

type Generator
type Generator struct {
}

Generator represents a UUID generator that generates UUIDs in sequence from a random starting point.

func MustNewGenerator
func MustNewGenerator() *Generator

MustNewGenerator is like NewGenerator but panics on failure.

func NewGenerator
func NewGenerator() (*Generator, error)

NewGenerator returns a new Generator. It can fail if the crypto/rand read fails.

func (*Generator) Next
func (g *Generator) Next() [24]byte

Next returns the next UUID from the generator. Only the first 8 bytes can differ from the previous UUID, so taking a slice of the first 16 bytes is sufficient to provide a somewhat less secure 128 bit UUID.

It is OK to call this method concurrently.

Documentation

Overview

Package fastuuid provides fast UUID generation of 192 bit universally unique identifiers. It does not provide formatting or parsing of the identifiers (it is assumed that a simple hexadecimal or base64 representation is sufficient, for which adequate functionality exists elsewhere).

Note that the generated UUIDs are not unguessable - each UUID generated from a Generator is adjacent to the previously generated UUID.

It ignores RFC 4122.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

Generator represents a UUID generator that generates UUIDs in sequence from a random starting point.

func MustNewGenerator

func MustNewGenerator() *Generator

MustNewGenerator is like NewGenerator but panics on failure.

func NewGenerator

func NewGenerator() (*Generator, error)

NewGenerator returns a new Generator. It can fail if the crypto/rand read fails.

func (*Generator) Next

func (g *Generator) Next() [24]byte

Next returns the next UUID from the generator. Only the first 8 bytes can differ from the previous UUID, so taking a slice of the first 16 bytes is sufficient to provide a somewhat less secure 128 bit UUID.

It is OK to call this method concurrently.

Jump to

Keyboard shortcuts

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