ulidgen

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2019 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package ulidgen generates ULIDs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

type Clock interface {
	// Now provides the time part of the ULID.
	Now() time.Time
}

Clock provides the time part of the ULID.

type Generator

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

Generator generates a ULID.

func NewGenerator

func NewGenerator(opts ...Option) *Generator

NewGenerator returns a new ULID generator.

func (*Generator) Generate added in v0.2.0

func (g *Generator) Generate() (string, error)

Generate generates a new ID.

type Option added in v0.3.0

type Option interface {
	// contains filtered or unexported methods
}

Option configures a Generator using the functional options paradigm popularized by Rob Pike and Dave Cheney. If you're unfamiliar with this style, see https://commandcenter.blogspot.com/2014/01/self-referential-functions-and-design.html and https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis.

func EntropySource added in v0.3.0

func EntropySource(entropy io.Reader) Option

EntropySource configures an entropy source of a generator.

func TimeSource added in v0.3.0

func TimeSource(clock Clock) Option

TimeSource configures a time source of a generator.

Jump to

Keyboard shortcuts

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