Documentation ¶
Overview ¶
Package uid provides functions to generate roughly time ordered unique identifiers. The implementation is based on the MongoDB ObjectId specification. See https://docs.mongodb.com/manual/reference/method/ObjectId/
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NextID ¶
NextID returns a new uid without requiring an instance of the generator. This is functionally identical, but incurs the additional overhead of setting up the generator on each request.
func NextStringID ¶
NextStringID returns a new uid without requiring an instance of the generator. This is functionally identical, but incurs the additional overhead of setting up the generator on each request.
Types ¶
type Gen ¶
type Gen struct {
// contains filtered or unexported fields
}
Gen represents a uid generator
func NewGenerator ¶
func NewGenerator() *Gen
NewGenerator returns an instance of a UID generator. During initialisation it generates the machine and process identifiers.
func (*Gen) NextID ¶
NextID returns the next uid in the sequence or an error if a valid uid could not be generated.
func (*Gen) NextStringID ¶
NextStringID returns the next uid in the sequence as a hexadecimal string or an error if a valid uid could not be generated.