Documentation ¶
Overview ¶
Package uid supports generating unique IDs. Its chief purpose is to prevent multiple test executions from interfering with each other, and to facilitate cleanup of old entities that may remain if tests exit early.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { Sep rune // Separates parts of the UID. Defaults to '-'. Time time.Time // Timestamp for all UIDs made with this space. Defaults to current time. }
Options are optional values for a Space.
type Space ¶
type Space struct { Prefix string // Prefix of UIDs. Read-only. Sep rune // Separates UID parts. Read-only. Time time.Time // Timestamp for UIDs. Read-only. // contains filtered or unexported fields }
A Space manages a set of unique IDs distinguished by a prefix.
func (*Space) New ¶
New generates a new unique ID. The ID consists of the Space's prefix, a timestamp, and a counter value. All unique IDs generated in the same test execution will have the same timestamp.
Aside from the characters in the prefix, IDs contain only letters, numbers and sep.
Click to show internal directories.
Click to hide internal directories.