// NewUUIDv5 generates a new UUID based on version 5 (SHA1 hash of a namespace
// and a name).
434885
func NewUUIDv5(ns UUID, name []byte) (UUID, error) {
	uuid := UUID{}
	hash := sha1.New()
	hash.Write(ns.dump())
	hash.Write(name)
	copy(uuid[:], hash.Sum([]byte{})[:16])

	uuid.setVersion(UUIDv5)
	uuid.setVariant(UUIDVariantRFC4122)
	return uuid, nil
}
1029991
func New() KSUID {
	ksuid, err := NewRandom()
	if err != nil {
		panic(fmt.Sprintf("Couldn't generate KSUID, inconceivable! error: %v", err))
	}
	return ksuid
}
390180
func (o *Generator) NewHash(hash hash.Hash, names ...interface{}) UUID {
	id := UUID{}
	id.unmarshal(digest(hash, []byte{}, names...))
	id[versionIndex] &= 0x0f
	id[versionIndex] |= uint8(0 << 4)
	id[variantIndex] &= variantSet
	id[variantIndex] |= VariantFuture
	return id
}
1116578
func New(data []byte) UUID {
	o := UUID{}
	o.unmarshal(data)
	return o
}
297586
func GenUUID() string {
	uuid := make([]byte, 24)
	n, err := rand.Read(uuid)
	if n != len(uuid) || err != nil {
		log.Fatal("can't generate uuid")
		return ""
	}
	// TODO: verify the two lines implement RFC 4122 correctly
	uuid[8] = 0x80 // variant bits see page 5
	uuid[4] = 0x40 // version 4 Pseudo Random, see page 7

	str := hex.EncodeToString(uuid)
	return fmt.Sprintf("%s-%s-%s-%s-%s", str[:8], str[9:13], str[14:18], str[19:23], str[29:])
}
1081133
func (f *UUIDFuncs) V1() (string, error) {
	u, err := uuid.NewUUID()
	if err != nil {
		return "", err
	}
	return u.String(), nil
}
1030805
func NewV4() UUID {
	u := UUID{}
	safeRandom(u[:])
	u.SetVersion(4)
	u.SetVariant()

	return u
}
778981
func NewuidmapPath(newuidmapPath string) func(*LinuxFactory) error {
	return func(l *LinuxFactory) error {
		l.NewuidmapPath = newuidmapPath
		return nil
	}
}
845391
func GenerateUUID() (string, error) {
	buf, err := GenerateRandomBytes(uuidLen)
	if err != nil {
		return "", err
	}
	return FormatUUID(buf)
}
835828
func (s *GetEventSourceMappingInput) SetUUID(v string) *GetEventSourceMappingInput {
	s.UUID = &v
	return s
}
429477
func NewUUID() (*UUID, error) {
	u := &UUID{}
	if _, err := rand.Read(u[:]); err != nil {
		return nil, err
	}
	u.setVariant(reservedRFC4122)
	u.setVersion(4)
	return u, nil
}
1159948
func NewUUID(domain Domain) ([]byte, error) {
	uuid, err := timebased.NewUUID()
	if err != nil {
		return nil, err
	}

	switch domain {
	case User:
		uid := os.Getuid()
		binary.BigEndian.PutUint32(uuid[0:], uint32(uid)) // network byte order
	case Group:
		gid := os.Getgid()
		binary.BigEndian.PutUint32(uuid[0:], uint32(gid)) // network byte order
	default:
		return nil, errors.New("domain is invalid")
	}

	// set version(v2)
	internal.SetVersion(uuid, internal.VersionDCESecurity)
	// set layout(RFC4122)
	internal.SetLayout(uuid, internal.LayoutRFC4122)

	return uuid, nil
}
920558
func (c *ClusterManager) Uuid() string {
	if len(c.config.ClusterUuid) == 0 {
		return c.config.ClusterId
	}
	return c.config.ClusterUuid
}
1097640
func (c *Controller) ModelUUIDs() []string {
	c.mu.Lock()

	result := make([]string, 0, len(c.models))
	for uuid := range c.models {
		result = append(result, uuid)
	}

	c.mu.Unlock()
	return result
}
1292607
func NewID(b []byte) (sha1, error) {
	if len(b) != 20 {
		return sha1{}, fmt.Errorf("Length must be 20: %v", b)
	}
	return MustID(b), nil
}
712778
func NewV1() UUID {
	u := UUID{}

	timeNow, clockSeq, hardwareAddr := getStorage()

	binary.BigEndian.PutUint32(u[0:], uint32(timeNow))
	binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>32))
	binary.BigEndian.PutUint16(u[6:], uint16(timeNow>>48))
	binary.BigEndian.PutUint16(u[8:], clockSeq)

	copy(u[10:], hardwareAddr)

	u.SetVersion(1)
	u.SetVariant()

	return u
}
1226937
func newUUID() (string, error) {
	uuid := make([]byte, 16)
	if _, err := io.ReadFull(rand.Reader, uuid); err != nil {
		return "", err
	}
	// variant bits; see section 4.1.1
	uuid[8] = uuid[8]&^0xc0 | 0x80
	// version 4 (pseudo-random); see section 4.1.3
	uuid[6] = uuid[6]&^0xf0 | 0x40
	return fmt.Sprintf("%x-%x-%x-%x-%x", uuid[0:4], uuid[4:6], uuid[6:8], uuid[8:10], uuid[10:]), nil
}