uid

package
v1.70.8 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package uid provides fast functions to generate simple time-and-random-based unique identifiers. Deprecated: use github.com/Vonage/gosrvlib/pkg/uidc package instead.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitRandSeed

func InitRandSeed() error

InitRandSeed initialize the random generator seed. You have to call this first and only once. Deprecated: use github.com/Vonage/gosrvlib/pkg/uidc package instead.

func NewID128

func NewID128() string

NewID128 generates and return a new base-36-string-formatted 128 bit unique ID based on time (high 64 bit) and a random number (low 64 bit). Deprecated: use github.com/Vonage/gosrvlib/pkg/uidc package instead.

Example
package main

import (
	"fmt"
	"log"

	"github.com/Vonage/gosrvlib/pkg/uid"
)

func main() {
	err := uid.InitRandSeed()
	if err != nil {
		log.Fatal(err)
	}

	v := uid.NewID128()

	fmt.Println(v)
}
Output:

func NewID64

func NewID64() string

NewID64 generates and return a new base-36-string-formatted 64 bit unique ID based on time (high 32 bit) and a random number (low 32 bit). NOTE: the zero time is set to the 1st of january of 10 year ago. Deprecated: use github.com/Vonage/gosrvlib/pkg/uidc package instead.

Example
package main

import (
	"fmt"
	"log"

	"github.com/Vonage/gosrvlib/pkg/uid"
)

func main() {
	err := uid.InitRandSeed()
	if err != nil {
		log.Fatal(err)
	}

	v := uid.NewID64()

	fmt.Println(v)
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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