granitic: Index | Files

package uuid

import ""

Package uuid provides tools for generating and validating various RFC 4122 compliant UUIDs

Default V4 UUID generation is benchmarked at ~500ns per generation (2.6 GHz Core i7 (I7-8850H)) and does not benefit from any buffering/pre-generation.


Package Files

v4.go validate.go

func Base32Encoder Uses

func Base32Encoder(asBytes Bytes16) string

Base32Encoder encodes the supplied 128 bit number as a base32 string

func Base64Encoder Uses

func Base64Encoder(asBytes Bytes16) string

Base64Encoder encodes the supplied 128 bit number as a base32 string

func StandardEncoder Uses

func StandardEncoder(asBytes Bytes16) string

StandardEncoder encodes the supplied 128 bit number as a standard dash separated UUID

func V4 Uses

func V4() string

V4 returns a valid V4 UUID using the default random number generator with no uniqueness checks

func V4Custom Uses

func V4Custom(gen Generate16Byte, e EncodeFrom16Byte) string

V4Custom returns a valid V4 UUID with a custom random number generator and EncodeFrom16Byte

func ValidFormat Uses

func ValidFormat(uuid string) bool

ValidFormat returns true if the supplied string is in accordance with the ABNF defined in Section 3 of RFC 4122

func ValidV4 Uses

func ValidV4(uuid string) bool

ValidV4 returns true if the supplied string is a valid version 4 UUID according to RFC 4122

type Bytes16 Uses

type Bytes16 [16]byte

Bytes16 is a 128-bit number represented as 16 bytes

func GenerateCryptoRand Uses

func GenerateCryptoRand() Bytes16

GenerateCryptoRand creates a random 128 bit number using crypto/rand.Reader as a source

type EncodeFrom16Byte Uses

type EncodeFrom16Byte func(Bytes16) string

EncodeFrom16Byte takes a 16 byte/128-bit representation of a UUID and encodes it as a string

type Generate16Byte Uses

type Generate16Byte func() Bytes16

Generate16Byte is a type of function able to create unsigned 128-bit numbers represented as a sequence of 16 bytes.

Package uuid imports 7 packages (graph). Updated 2019-10-28. Refresh now. Tools for package owners.