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

Function NewRandom

version4.go:39–44  ·  view source on GitHub ↗

NewRandom returns a Random (Version 4) UUID. The strength of the UUIDs is based on the strength of the crypto/rand package. Uses the randomness pool if it was enabled with EnableRandPool. A note about uniqueness derived from the UUID Wikipedia entry: Randomly generated UUIDs have 122 random bits

()

Source from the content-addressed store, hash-verified

37// equivalent to the odds of creating a few tens of trillions of UUIDs in a
38// year and having one duplicate.
39func NewRandom() (UUID, error) {
40 if !poolEnabled {
41 return NewRandomFromReader(rander)
42 }
43 return newRandomFromPool()
44}
45
46// NewRandomFromReader returns a UUID based on bytes read from a given io.Reader.
47func NewRandomFromReader(r io.Reader) (UUID, error) {

Callers 6

NewFunction · 0.85
NewStringFunction · 0.85
NewV7Function · 0.85
TestRandPoolFunction · 0.85
BenchmarkUUID_NewFunction · 0.85
BenchmarkUUID_NewPooledFunction · 0.85

Calls 2

NewRandomFromReaderFunction · 0.85
newRandomFromPoolFunction · 0.85

Tested by 3

TestRandPoolFunction · 0.68
BenchmarkUUID_NewFunction · 0.68
BenchmarkUUID_NewPooledFunction · 0.68