Fresh dep ensure

This commit is contained in:
Mike Cronce
2018-11-26 13:23:56 -05:00
parent 93cb8a04d7
commit 407478ab9a
9016 changed files with 551394 additions and 279685 deletions

View File

@ -8,9 +8,9 @@ import (
"bytes"
"crypto/rand"
"encoding/hex"
"fmt"
"io"
"strings"
guuid "github.com/google/uuid"
)
// Array is a pass-by-value UUID that can be used as an effecient key in a map.
@ -24,7 +24,7 @@ func (uuid Array) UUID() UUID {
// String returns the string representation of uuid,
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
func (uuid Array) String() string {
return uuid.UUID().String()
return guuid.UUID(uuid).String()
}
// A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC
@ -32,18 +32,18 @@ func (uuid Array) String() string {
type UUID []byte
// A Version represents a UUIDs version.
type Version byte
type Version = guuid.Version
// A Variant represents a UUIDs variant.
type Variant byte
type Variant = guuid.Variant
// Constants returned by Variant.
const (
Invalid = Variant(iota) // Invalid UUID
RFC4122 // The variant specified in RFC4122
Reserved // Reserved, NCS backward compatibility.
Microsoft // Reserved, Microsoft Corporation backward compatibility.
Future // Reserved for future definition.
Invalid = guuid.Invalid // Invalid UUID
RFC4122 = guuid.RFC4122 // The variant specified in RFC4122
Reserved = guuid.Reserved // Reserved, NCS backward compatibility.
Microsoft = guuid.Microsoft // Reserved, Microsoft Corporation backward compatibility.
Future = guuid.Future // Reserved for future definition.
)
var rander = rand.Reader // random function
@ -58,31 +58,20 @@ func New() string {
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and
// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded.
func Parse(s string) 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
gu, err := guuid.Parse(s)
if err == nil {
return gu[:]
}
if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' {
return nil
return nil
}
// ParseBytes is like Parse, except it parses a byte slice instead of a string.
func ParseBytes(b []byte) (UUID, error) {
gu, err := guuid.ParseBytes(b)
if err == nil {
return gu[:], nil
}
var uuid [16]byte
for i, x := range [16]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[:]
return nil, err
}
// Equal returns true if uuid1 and uuid2 are equal.
@ -163,29 +152,6 @@ func (uuid UUID) Version() (Version, bool) {
return Version(uuid[6] >> 4), true
}
func (v Version) String() string {
if v > 15 {
return fmt.Sprintf("BAD_VERSION_%d", v)
}
return fmt.Sprintf("VERSION_%d", v)
}
func (v Variant) String() string {
switch v {
case RFC4122:
return "RFC4122"
case Reserved:
return "Reserved"
case Microsoft:
return "Microsoft"
case Future:
return "Future"
case Invalid:
return "Invalid"
}
return fmt.Sprintf("BadVariant%d", int(v))
}
// SetRand sets the random number generator to r, which implements io.Reader.
// If r.Read returns an error when the package requests random data then
// a panic will be issued.
@ -193,9 +159,5 @@ func (v Variant) String() string {
// Calling SetRand with nil sets the random number generator to the default
// generator.
func SetRand(r io.Reader) {
if r == nil {
rander = rand.Reader
return
}
rander = r
guuid.SetRand(r)
}