uuid

package
v0.0.0-...-5cef3e7 Latest Latest
Warning

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

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

Documentation

Overview

Package uuid can be used to generate 128 bit UUIDs compatible with rfc4122. Currently, only version 4 UUIDs, UUIDs generated from random data, can be created. The package includes functions for generating UUIDs and for converting them to and from strings.

Index

Constants

View Source
const UUIDRegex = "[a-fA-F0-9]{8}-?[a-fA-F0-9]{4}-?4[a-fA-F0-9]{3}-?[8|9|aA|bB][a-fA-F0-9]{3}-?[a-fA-F0-9]{12}"

UUIDRegex defines a pattern for validating UUIDs

Variables

View Source
var (
	// ErrUUIDInvalid indicates that a UIID is invalid.  Currently,
	// returned by uuid.Parse if the string passed to this function
	// does not contain a valid UUID.
	ErrUUIDInvalid = errors.New("invalid uuid")
)

Functions

This section is empty.

Types

type UUID

type UUID [16]byte

UUID represents a single 128 bit UUID as an array of 16 bytes.

func Generate

func Generate() UUID

Generate generates a new v4 UUID, i.e., a random UUID.

func Parse

func Parse(s string) (UUID, error)

Parse returns the binary encoding of the UUID passed in the s parameter. The error ErrUUIDInvalid will be returned if s does not represent a valid UUID.

func (UUID) String

func (u UUID) String() string

Jump to

Keyboard shortcuts

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