Documentation
¶
Overview ¶
Package idgen produces identifiers.
These identifiers have the following properties:
- unique (~128 bit of randomness)
- usable as DNS label (strict RFC1035, no digits in first position)
- reasonably easy for humans to manipulate (see http://philzimmermann.com/docs/human-oriented-base-32-encoding.txt)
- reasonably short (26 characters)
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RE = regexp.MustCompile(fmt.Sprintf("[%s]{%d}", zBase32Alphabet, divCeil(idBytes*8, 5)))
RE is a (fragment of) a regular expression that matches a possible ID.
Functions ¶
Types ¶
type Generator ¶
type Generator interface {
// ID generates a new unique identifier
ID() string
}
Generator is a generator of unique identifiers.
var Random Generator = randomGenerator{}
Random is the global ID generator that produces random identifiers.
func FromContext ¶
FromContext returns the Generator that WithGenerator has injected into the context.
func NewConstant ¶
NewConstant returns new generator that produces a constant ID once.
func NewDeterministic ¶
NewDeterministic creates new deterministic ID generator. Generators with the same key will produce exactly the same identifier sequences.
Click to show internal directories.
Click to hide internal directories.