@@ -269,13 +269,16 @@ func (g *Gen) NewV5(ns UUID, name string) UUID {
269
269
return u
270
270
}
271
271
272
- // NewV6 returns a k-sortable UUID based on a timestamp and 48 bits of
272
+ // NewV6 returns a k-sortable UUID based on the current timestamp and 48 bits of
273
273
// pseudorandom data. The timestamp in a V6 UUID is the same as V1, with the bit
274
274
// order being adjusted to allow the UUID to be k-sortable.
275
275
func (g * Gen ) NewV6 () (UUID , error ) {
276
276
return g .NewV6AtTime (g .epochFunc ())
277
277
}
278
278
279
+ // NewV6 returns a k-sortable UUID based on the provided timestamp and 48 bits of
280
+ // pseudorandom data. The timestamp in a V6 UUID is the same as V1, with the bit
281
+ // order being adjusted to allow the UUID to be k-sortable.
279
282
func (g * Gen ) NewV6AtTime (atTime time.Time ) (UUID , error ) {
280
283
/* https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-6
281
284
0 1 2 3
@@ -315,12 +318,14 @@ func (g *Gen) NewV6AtTime(atTime time.Time) (UUID, error) {
315
318
return u , nil
316
319
}
317
320
318
- // NewV7 returns a k-sortable UUID based on the current millisecond precision
321
+ // NewV7 returns a k-sortable UUID based on the current millisecond- precision
319
322
// UNIX epoch and 74 bits of pseudorandom data.
320
323
func (g * Gen ) NewV7 () (UUID , error ) {
321
324
return g .NewV7AtTime (g .epochFunc ())
322
325
}
323
326
327
+ // NewV7 returns a k-sortable UUID based on the provided millisecond-precision
328
+ // UNIX epoch and 74 bits of pseudorandom data.
324
329
func (g * Gen ) NewV7AtTime (atTime time.Time ) (UUID , error ) {
325
330
var u UUID
326
331
/* https://datatracker.ietf.org/doc/html/rfc9562#name-uuid-version-7
@@ -368,11 +373,12 @@ func (g *Gen) NewV7AtTime(atTime time.Time) (UUID, error) {
368
373
return u , nil
369
374
}
370
375
371
- // getClockSequence returns the epoch and clock sequence for V1,V6 and V7 UUIDs.
372
- //
373
- // When useUnixTSMs is false, it uses the Coordinated Universal Time (UTC) as a count of 100-
376
+ // getClockSequence returns the epoch and clock sequence of the provided time,
377
+ // used for generating V1,V6 and V7 UUIDs.
374
378
//
375
- // nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to the Christian calendar).
379
+ // When useUnixTSMs is false, it uses the Coordinated Universal Time (UTC) as a count of
380
+ // 100-nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian
381
+ // reform to the Christian calendar).
376
382
func (g * Gen ) getClockSequence (useUnixTSMs bool , atTime time.Time ) (uint64 , uint16 , error ) {
377
383
var err error
378
384
g .clockSequenceOnce .Do (func () {
@@ -430,7 +436,7 @@ func (g *Gen) getHardwareAddr() ([]byte, error) {
430
436
}
431
437
432
438
// Returns the difference between UUID epoch (October 15, 1582)
433
- // and current time in 100-nanosecond intervals.
439
+ // and the provided time in 100-nanosecond intervals.
434
440
func (g * Gen ) getEpoch (atTime time.Time ) uint64 {
435
441
return epochStart + uint64 (atTime .UnixNano ()/ 100 )
436
442
}
0 commit comments