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

Function newRandomFromPool

version4.go:58–76  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56}
57
58func newRandomFromPool() (UUID, error) {
59 var uuid UUID
60 poolMu.Lock()
61 if poolPos == randPoolSize {
62 _, err := io.ReadFull(rander, pool[:])
63 if err != nil {
64 poolMu.Unlock()
65 return Nil, err
66 }
67 poolPos = 0
68 }
69 copy(uuid[:], pool[poolPos:(poolPos+16)])
70 poolPos += 16
71 poolMu.Unlock()
72
73 uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4
74 uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10
75 return uuid, nil
76}

Callers 1

NewRandomFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected