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

Function NewRandomFromReader

version4.go:47–56  ·  view source on GitHub ↗

NewRandomFromReader returns a UUID based on bytes read from a given io.Reader.

(r io.Reader)

Source from the content-addressed store, hash-verified

45
46// NewRandomFromReader returns a UUID based on bytes read from a given io.Reader.
47func NewRandomFromReader(r io.Reader) (UUID, error) {
48 var uuid UUID
49 _, err := io.ReadFull(r, uuid[:])
50 if err != nil {
51 return Nil, err
52 }
53 uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4
54 uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10
55 return uuid, nil
56}
57
58func newRandomFromPool() (UUID, error) {
59 var uuid UUID

Callers 3

NewRandomFunction · 0.85
NewV7FromReaderFunction · 0.85
TestRandomFromReaderFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestRandomFromReaderFunction · 0.68