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

Function generateV6

version6.go:48–83  ·  view source on GitHub ↗
(now Time, seq uint16)

Source from the content-addressed store, hash-verified

46}
47
48func generateV6(now Time, seq uint16) UUID {
49 var uuid UUID
50
51 /*
52 0 1 2 3
53 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
54 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
55 | time_high |
56 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
57 | time_mid | time_low_and_version |
58 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
59 |clk_seq_hi_res | clk_seq_low | node (0-1) |
60 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 | node (2-5) |
62 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
63 */
64
65 timeHigh := uint32((now >> 28) & 0xffffffff)
66 timeMid := uint16((now >> 12) & 0xffff)
67 timeLow := uint16(now & 0x0fff)
68 timeLow |= 0x6000 // Version 6
69
70 binary.BigEndian.PutUint32(uuid[0:], timeHigh)
71 binary.BigEndian.PutUint16(uuid[4:], timeMid)
72 binary.BigEndian.PutUint16(uuid[6:], timeLow)
73 binary.BigEndian.PutUint16(uuid[8:], seq)
74
75 nodeMu.Lock()
76 if nodeID == zeroID {
77 setNodeInterface("")
78 }
79 copy(uuid[10:], nodeID[:])
80 nodeMu.Unlock()
81
82 return uuid
83}

Callers 2

NewV6Function · 0.85
NewV6WithTimeFunction · 0.85

Calls 1

setNodeInterfaceFunction · 0.85

Tested by

no test coverage detected