guid

package
v0.0.0-...-d7ca77a Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package guid implements a thread-safe ID generator. The returned ID will be unique for a given process, but will not be globally unique. This is because it uses the system clock and a sequence.

The ID returned is YYYYMMDD-HH24MI-SSSS-SSSS-NNNNNNNNNNNN, where the date is UTC and N is a zero-padded sequence that starts at zero.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

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

Generator holds our lock and current value.

func New

func New(seq int) *Generator

New returns a new generator starting at the sequence. It's useful if you're interested in restoring a generator.

func (*Generator) CurrVal

func (g *Generator) CurrVal() int

CurrVal returns the current value of the sequence.

func (*Generator) Next

func (g *Generator) Next() string

Next returns a string that looks like a UUID.

func (*Generator) NextVal

func (g *Generator) NextVal() int

NextVal increments the sequence, then returns the new value.

Jump to

Keyboard shortcuts

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