uuid

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

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

https://tools.ietf.org/html/rfc4122

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base32Encoder

func Base32Encoder(asBytes Bytes16) string

Base32Encoder encodes the supplied 128 bit number as a base32 string

func Base64Encoder

func Base64Encoder(asBytes Bytes16) string

Base64Encoder encodes the supplied 128 bit number as a base32 string

func StandardEncoder

func StandardEncoder(asBytes Bytes16) string

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

func V4

func V4() string

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

func V4Custom

func V4Custom(gen Generate16Byte, e EncodeFrom16Byte) string

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

func ValidFormat

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

func ValidV4(uuid string) bool

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

Types

type Bytes16

type Bytes16 [16]byte

Bytes16 is a 128-bit number represented as 16 bytes

func GenerateCryptoRand

func GenerateCryptoRand() Bytes16

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

type EncodeFrom16Byte

type EncodeFrom16Byte func(Bytes16) string

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

type Generate16Byte

type Generate16Byte func() Bytes16

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

Jump to

Keyboard shortcuts

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