guid

package
v1.15.2-0...-1a0745b Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package guid provides simple and high performance unique id generation functionality.

Unique String ID: PLEASE VERY NOTE: This package only provides unique number generation for simple, convenient and most common usage purpose, but does not provide strict global unique number generation. Please refer to UUID algorithm for global unique number generation if necessary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func S

func S(data ...[]byte) string

S creates and returns a global unique string in 32 bytes that meets most common usages without strict UUID algorithm. It returns an unique string using default unique algorithm if no <data> is given.

The specified <data> can be no more than 2 parts. No matter how long each of the <data> size is, each of them will be hashed into 7 bytes as part of the result. If given <data> parts is less than 2, the leftover size of the result bytes will be token by random string.

The returned string is composed with: 1. Default: MAC(7) + PID(4) + TimestampNano(12) + Sequence(3) + RandomString(6) 2. CustomData: Data(7/14) + TimestampNano(12) + Sequence(3) + RandomString(3/10)

Note that:

  1. The returned length is fixed to 32 bytes for performance purpose.
  2. The custom parameter <data> composed should have unique attribute in your business situation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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