idgen

package module
v0.0.0-...-e7e045c Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2018 License: Apache-2.0 Imports: 3 Imported by: 4

README

turbinelabs/idgen

This project is no longer maintained by Turbine Labs, which has shut down.

Apache 2.0 GoDoc CircleCI Go Report Card codecov

The idgen project defines an ID type, and the IDGen type, which can be used to generate IDs. It also defines several IDGen implementations, including UUID and counter-based.

Requirements

  • Go 1.9 or later (previous versions may work, but we don't build or test against them)

Dependencies

The idgen project has no external dependencies; the tests depend on our test package. It should always be safe to use HEAD of all master branches of Turbine Labs open source projects together, or to vendor them with the same git tag.

Additionally, we vendor github.com/nu7hatch/gouuid. This should be considered an opaque implementation detail, see Vendoring for more discussion.

Install

go get -u github.com/turbinelabs/idgen/...

Clone/Test

mkdir -p $GOPATH/src/turbinelabs
git clone https://github.com/turbinelabs/idgen.git > $GOPATH/src/turbinelabs/idgen
go test github.com/turbinelabs/idgen/...

Godoc

idgen

Versioning

Please see Versioning of Turbine Labs Open Source Projects.

Pull Requests

Patches accepted! Please see Contributing to Turbine Labs Open Source Projects.

Code of Conduct

All Turbine Labs open-sourced projects are released with a Contributor Code of Conduct. By participating in our projects you agree to abide by its terms, which will be carefully enforced.

Documentation

Overview

Package idgen defines an ID type, and the IDGen type, which can be used to generate IDs. It also defines several IDGen implementations.

Index

Constants

View Source
const NilID = ID("")

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID string

type IDGen

type IDGen func() (ID, error)

IDGen is a function that generates either an ID or an error

func NewCounter

func NewCounter(start uint64) IDGen

NewCounter produces an IDGen which will produce IDs derived from a counter, offset from the given start value. Each call to the function will atomically increment the underlyinc counter. This IDGen should only be used for testing, when predictable ID values are needed.

func NewPrefixing

func NewPrefixing(prefix string, newID IDGen) IDGen

NewPrefixing produces an IDGen which will apply the given prefix string to IDs generated by the given IDGen

func NewUUID

func NewUUID() IDGen

NewUUID produces an IDGen which will produce v4 UUIDs.

Jump to

Keyboard shortcuts

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