MCPcopy
hub / github.com/google/uuid / NewV6WithTime

Function NewV6WithTime

version6.go:39–46  ·  view source on GitHub ↗

NewV6WithTime returns a Version 6 UUID based on the current NodeID, clock sequence, and a specified time. It is similar to the NewV6 function, but allows you to specify the time. If time is passed as nil, then the current time is used. There is a limit on how many UUIDs can be generated for the sam

(customTime *time.Time)

Source from the content-addressed store, hash-verified

37// are generating multiple UUIDs, it is recommended to increment the time.
38// If getTime fails to return the current NewV6WithTime returns Nil and an error.
39func NewV6WithTime(customTime *time.Time) (UUID, error) {
40 now, seq, err := getTime(customTime)
41 if err != nil {
42 return Nil, err
43 }
44
45 return generateV6(now, seq), nil
46}
47
48func generateV6(now Time, seq uint16) UUID {
49 var uuid UUID

Callers 3

TestNewV6WithTimeFunction · 0.85
BenchmarkNewV6WithTimeFunction · 0.85

Calls 2

getTimeFunction · 0.85
generateV6Function · 0.85

Tested by 3

TestNewV6WithTimeFunction · 0.68
BenchmarkNewV6WithTimeFunction · 0.68