OrderedUUIDv1

package module
v0.0.0-...-76aab6e Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 3 Imported by: 0

README

UUID V1 Orderer

Github CI

Ordering UUID V1 bytes by inserted timestamp for practical purposes. If you want to store UUID's sequentially in databases, you can use this library.

Requirement

Go 1.14 ~ 1.15, other versions not tested

Instalation

Add it in your project: go get github.com/MufidJamaluddin/uuidv1_orderer

How to Use

  1. Ordering Existing UUID's
unorderedUuid := UUIDStringToBytes("c5db1800-ce4c-11de-a5e2-1b45123c6e98")

orderedUuid := ToOrderedUuid(unorderedUuid)

orderedUuidStr := UUIDBytesToString(orderedUuid)

// next, your logic
  1. Transform Back to Standard UUID V1
orderedUuid := UUIDStringToBytes("11dece4c-c5db-1800-a5e2-1b45123c6e98")

standardUuidV1 := FromOrderedUuid(orderedUuid)

standardUuidV1Str := UUIDBytesToString(standardUuidV1)

// next, your logic

Notes

The differences explanation between ordered and standard UUID V1 is bellow

UUID V1 In String

Example: c5db1800-ce4c-11de-a5e2-1b45123c6e98

Meaning:

  1. Timestamp 1de-ce4c-c5db1800 in c5db1800-ce4c-11de
  2. Standard UUID version 1 in c5db1800-ce4c-(1)1de
  3. Clock sequence a5e2
  4. Standard MAC Address or Nonstandard Random IDs 1b45123c6e98
Ordered UUID V1

Reorder timestamp to it's origin form with UUID version on top.

Example: 11dece4c-c5db-1800-a5e2-1b45123c6e98

Licenses

(c) Mufid Jamaluddin. MIT Licenses

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromOrderedUuid

func FromOrderedUuid(uid [16]byte) (newUid [16]byte)

func ToOrderedUuid

func ToOrderedUuid(uid [16]byte) (newUid [16]byte)

func UUIDBytesToString

func UUIDBytesToString(uuid [16]byte) (ns string)

func UUIDStringToBytes

func UUIDStringToBytes(suid string) (uuid [16]byte)

Types

This section is empty.

Jump to

Keyboard shortcuts

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