goid

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2018 License: MIT Imports: 5 Imported by: 25

README

Goid

A Go package to generate V4 UUIDs

Go Report Card cover.run Go Docs

Documentation

The API docs can be viewed here or generated with godoc.

Usage

An example of generating a v4 UUID and outputting it

import (
    "fmt"
    "github.com/jakehl/goid"
)

func main() {
    v4UUID := goid.NewV4UUID()
    fmt.Println(v4UUID)
}

Notes

Contributing & Package status

Currently this package should generate RFC4122 compliant Version 4 UUIDs and the existing APIs to do so should not change. New features may be added via pull requests, however they should not touch existing APIs

Todo
  • Add optimised bulk UUID generation
References

The following sources were referenced during the development of this project

Documentation

Overview

Package goid provides the tools needed to produce and manipulate V4 UUIDs

Index

Constants

View Source
const V4UUIDRegex = "\\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}\\b"

V4UUIDRegex is a simple string regex that will match valid v4 UUIDs

Variables

This section is empty.

Functions

This section is empty.

Types

type UUID

type UUID [16]byte

UUID Represents a UUID

func GetUUIDFromByteSlice

func GetUUIDFromByteSlice(slice []byte) (*UUID, error)

GetUUIDFromByteSlice takes a slice of bytes and converts it to a UUID If the slice is not 16 bytes long it will return an error @TODO add version checking

func GetUUIDFromString

func GetUUIDFromString(strUUID string) (*UUID, error)

GetUUIDFromString takes a string representing a UUID and converts it to a UUID type Returns an error if the string does not match a UUID

func NewNilUUID

func NewNilUUID() *UUID

NewNilUUID returns a nil UUID (All bits set to zero)

func NewV4UUID

func NewV4UUID() (result *UUID)

NewV4UUID returns a randomized version 4 UUID

func (*UUID) Equals added in v1.1.0

func (u *UUID) Equals(comp *UUID) bool

func (*UUID) GetVersion

func (u *UUID) GetVersion() string

GetVersion returns the version of the UUID based on the 13th character (1st char of 7th byte) of the UUID

func (*UUID) String

func (u *UUID) String() string

ToString converts the UUID into its string representation

Directories

Path Synopsis
cmd module

Jump to

Keyboard shortcuts

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