// NewUUID62 returns a base-36 UUID with no dashes.
555698
func NewUUID62() (string, error) {
	b := make([]byte, 16)
	_, err := randSource.Read(b)
	if err != nil {
		return "", err
	}
	s := fmt.Sprintf("%x", b)
	return ConvertUp(s, base62alphabet), nil
}
586419
func (u *UUID) UnmarshalBinary(data []byte) (err error) {
	if len(data) != Size {
		err = fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data))
		return
	}
	copy(u[:], data)

	return
}
1005061
func (l *Literal) UUID() uuid.UUID {
	var buffer bytes.Buffer

	switch v := l.v.(type) {
	case bool:
		if v {
			buffer.WriteString("true")
		} else {
			buffer.WriteString("false")
		}
	case int64:
		b := make([]byte, 8)
		binary.PutVarint(b, v)
		buffer.Write(b)
	case float64:
		bs := math.Float64bits(v)
		b := make([]byte, 8)
		binary.LittleEndian.PutUint64(b, bs)
		buffer.Write(b)
	case string:
		buffer.Write([]byte(v))
	case []byte:
		buffer.Write(v)
	}

	return uuid.NewSHA1(uuid.NIL, buffer.Bytes())
}
34384
func (n *Node) UUID() uuid.UUID {
	var buffer bytes.Buffer
	buffer.WriteString(string(*n.t))
	buffer.WriteString(string(*n.id))
	return uuid.NewSHA1(uuid.NIL, buffer.Bytes())
}
1021188
func (o *Generator) NewV1() UUID {
	o.read()
	id := UUID{}

	makeUuid(&id,
		uint32(o.Timestamp),
		uint16(o.Timestamp>>32),
		uint16(o.Timestamp>>48),
		uint16(o.Sequence),
		o.Node)

	id.setRFC4122Version(VersionOne)
	return id
}
920558
func (c *ClusterManager) Uuid() string {
	if len(c.config.ClusterUuid) == 0 {
		return c.config.ClusterId
	}
	return c.config.ClusterUuid
}
1072163
func encodeUUID(src [16]byte) string {
	return fmt.Sprintf("%x-%x-%x-%x-%x", src[0:4], src[4:6], src[6:8], src[8:10], src[10:16])
}
522878
func (o *UUID) UnmarshalBinary(bytes []byte) error {
	if len(bytes) != o.Size() {
		return errors.New("uuid: invalid length")
	}
	o.unmarshal(bytes)
	return nil
}
242224
func NewUUID() ([]byte, error) {
	uuid := make([]byte, 16)
	n, err := rand.Read(uuid[:])
	if err != nil {
		return nil, errors.Wrap(err, "could not generate random bytes")
	}
	if n != len(uuid) {
		return nil, errors.New("could not generate random bytes with 16 length")
	}

	// set version(v4)
	internal.SetVersion(uuid, internal.VersionRandom)
	// set layout(RFC4122)
	internal.SetLayout(uuid, internal.LayoutRFC4122)

	return uuid, nil
}
589754
func UUID4() (u UUID) {
	// s := make([]byte, 16)
	// n, err := rand.Read(s)
	// if n != 16 || err != nil {
	// 	return nil
	// }

	for i, _ := range u {
		// u[i] = v
		u[i] = byte(rand.Int31n(256))
	}

	// Set the four most significant bits (bits 12 through 15) of the
	// time_hi_and_version field to the 4-bit version number from Section 4.1.3.
	u[6] = u[6]&0x0f | 0x40

	// Set the two most significant bits (bits 6 and 7) of the
	// clock_seq_hi_and_reserved to zero and one, respectively.
	u[8] = u[8]&0x3f | 0x80

	return u
}
1124535
func (p *Predicate) UUID() uuid.UUID {
	var buffer bytes.Buffer

	buffer.WriteString(string(p.id))
	if p.anchor == nil {
		buffer.WriteString("immutable")
	} else {
		b := make([]byte, 16)
		binary.PutVarint(b, p.anchor.UnixNano())
		buffer.Write(b)
	}

	return uuid.NewSHA1(uuid.NIL, buffer.Bytes())
}
1116578
func New(data []byte) UUID {
	o := UUID{}
	o.unmarshal(data)
	return o
}
623627
func createUUID() ([]byte, error) {
	b := make([]byte, 16)
	_, err := io.ReadFull(rand.Reader, b)
	if err != nil {
		return b, err
	}
	// variant bits; see section 4.1.1
	b[8] = b[8]&^0xc0 | 0x80
	// version 4 (pseudo-random); see section 4.1.3
	b[6] = b[6]&^0xf0 | 0x40
	return b, nil
}
160962
func NewNameBasedSHA1(namespace, name string) (UUID, error) {
	u, err := sha1.NewUUID(namespace, name)
	if err != nil {
		return Nil, err
	}

	uuid := UUID{}
	copy(uuid[:], u)

	return uuid, nil
}
1175043
func NewHex(uuid string) UUID {
	o := UUID{}
	o.unmarshal(fromHex(uuid))
	return o
}
92610
func NewV4() (u *UUID, err error) {
	u = new(UUID)
	// Set all bits to randomly (or pseudo-randomly) chosen values.
	_, err = rand.Read(u[:])
	if err != nil {
		return
	}
	u.setVariant(ReservedRFC4122)
	u.setVersion(4)
	return
}
497656
func parseUUID(s string) uuid {
	//If it is in no dash format "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
	if len(s) == 32 {
		uuid := make([]byte, 16)
		for i, x := range []int{
			0, 2, 4, 6, 8, 10,
			12, 14, 16, 18, 20,
			22, 24, 26, 28, 30} {
			if v, ok := xtob(s[x:]); !ok {
				return nil
			} else {
				uuid[i] = v
			}
		}
		return uuid
	}

	if len(s) == 36+9 {
		if strings.ToLower(s[:9]) != "urn:uuid:" {
			return nil
		}
		s = s[9:]
	} else if len(s) != 36 {
		return nil
	}
	if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' {
		return nil
	}
	uuid := make([]byte, 16)
	for i, x := range []int{
		0, 2, 4, 6,
		9, 11,
		14, 16,
		19, 21,
		24, 26, 28, 30, 32, 34} {
		if v, ok := xtob(s[x:]); !ok {
			return nil
		} else {
			uuid[i] = v
		}
	}
	return uuid
}