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. // Short, if true, makes the result of space.New shorter by 6 characters. // This can be useful for character restricted IDs. It will use a shorter // but less readable time representation, and will only use two characters // for the count suffix instead of four. // // e.x. normal: gotest-20181030-59751273685000-0001 // e.x. short: gotest-1540917351273685000-01 Short bool }
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.