You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
k3s/vendor/github.com/pborman/uuid/version4.go

27 lines
863 B

6 years ago
// Copyright 2011 Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package uuid
5 years ago
import guuid "github.com/google/uuid"
6 years ago
// Random returns a Random (Version 4) UUID or panics.
//
// The strength of the UUIDs is based on the strength of the crypto/rand
// package.
//
5 years ago
// A note about uniqueness derived from the UUID Wikipedia entry:
6 years ago
//
// Randomly generated UUIDs have 122 random bits. One's annual risk of being
// hit by a meteorite is estimated to be one chance in 17 billion, that
// means the probability is about 0.00000000006 (6 × 1011),
// equivalent to the odds of creating a few tens of trillions of UUIDs in a
// year and having one duplicate.
func NewRandom() UUID {
5 years ago
if gu, err := guuid.NewRandom(); err == nil {
return UUID(gu[:])
}
return nil
6 years ago
}