uuid

package module
v0.0.0-...-18dc48a Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2016 License: MIT Imports: 11 Imported by: 0

README

uuid

You're not a beautiful and unique snowflake, but your identifiers can be.

Build Status codecov Go Report Card

As you may of guessed this library provides RFC4122 compliant universally unique identifiers.

Example Usage

The uuid library provides a factory function for producing random version 4 UUIDs. This allows you to get the identification you want with no setup.

import (
	"fmt"

	"github.com/benjic/uuid"
)

func main() {
	id := uuid.Generate()
	fmt.Println(id)
}

Goals

  • Fast
    • Benchmark should prove this library can supply a bunch of identifiers really, really quickly.
  • Simple
    • If a consumer is fine with sane defaults consumption of library should be a simple factory function.
  • Configurable
    • If sane defaults are not ideal, a consumer should be able to configure the library to suit their needs.

Documentation

Overview

Package uuid is a simple library for generating RFC4122 compliant universally unique identifiers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	Version      Version
	Interfaces   []net.Interface
	RandomReader func([]byte) (int, error)
}

A Configuration provides sources of things.

type Generator

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

A Generator is a factory for creating new UUIDs

func NewGenerator

func NewGenerator(configuration Configuration) (g *Generator, err error)

NewGenerator creates a new UUID generator which operates with the given configuration.

func (*Generator) Generate

func (g *Generator) Generate() UUID

Generate produces a new UUID that reflects the configuration of the generator.

type NamespaceGenerator

type NamespaceGenerator struct {
	Namespace UUID
	Version   Version
	// contains filtered or unexported fields
}

A NamespaceGenerator allows consumers to generate UUIDs for a given namespace and name.

func NewNamespaceGenerator

func NewNamespaceGenerator(namespace UUID, configuration Configuration) (g *NamespaceGenerator, err error)

NewNamespaceGenerator creates a new UUID generator for the given namespace and configuration.

func (*NamespaceGenerator) Generate

func (g *NamespaceGenerator) Generate(name []byte) UUID

Generate procues a new UUID that refelcts the given

type UUID

type UUID []byte

A UUID is a unique identifier.

func Generate

func Generate() UUID

Generate provides a Version 4 random UUID

func Parse

func Parse(id string) (uuid UUID, err error)

Parse returns a UUID from a given string

func (UUID) String

func (id UUID) String() string

String provides a string representation of a UUID using the established dashed format.

func (UUID) Version

func (id UUID) Version() Version

Version of the UUID

type Version

type Version uint8

A Version dictates the generation of an UUID

Jump to

Keyboard shortcuts

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