dependencies: update github.com/gofrs/uuid v4.4.0
Signed-off-by: Humble Chirammal <humble.devassy@gmail.com>
This commit is contained in:
parent
9cfdf989ed
commit
b0d89a7807
2
go.mod
2
go.mod
@ -168,7 +168,7 @@ require (
|
|||||||
github.com/go-openapi/jsonreference v0.20.1 // indirect
|
github.com/go-openapi/jsonreference v0.20.1 // indirect
|
||||||
github.com/go-openapi/swag v0.22.3 // indirect
|
github.com/go-openapi/swag v0.22.3 // indirect
|
||||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
|
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible // indirect
|
github.com/gofrs/uuid v4.4.0+incompatible // indirect
|
||||||
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
||||||
github.com/google/btree v1.0.1 // indirect
|
github.com/google/btree v1.0.1 // indirect
|
||||||
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
|
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
|
||||||
|
4
go.sum
4
go.sum
@ -283,8 +283,8 @@ github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x
|
|||||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/godbus/dbus/v5 v5.0.6 h1:mkgN1ofwASrYnJ5W6U/BxG15eXXXjirgZc7CLqkcaro=
|
github.com/godbus/dbus/v5 v5.0.6 h1:mkgN1ofwASrYnJ5W6U/BxG15eXXXjirgZc7CLqkcaro=
|
||||||
github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4=
|
github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4=
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||||
|
@ -48,7 +48,7 @@ require (
|
|||||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||||
github.com/go-openapi/jsonreference v0.20.1 // indirect
|
github.com/go-openapi/jsonreference v0.20.1 // indirect
|
||||||
github.com/go-openapi/swag v0.22.3 // indirect
|
github.com/go-openapi/swag v0.22.3 // indirect
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible // indirect
|
github.com/gofrs/uuid v4.4.0+incompatible // indirect
|
||||||
github.com/gogo/protobuf v1.3.2 // indirect
|
github.com/gogo/protobuf v1.3.2 // indirect
|
||||||
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||||
|
4
staging/src/k8s.io/legacy-cloud-providers/go.sum
generated
4
staging/src/k8s.io/legacy-cloud-providers/go.sum
generated
@ -144,8 +144,8 @@ github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/
|
|||||||
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
|
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
|
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
|
||||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
|
22
vendor/github.com/gofrs/uuid/.travis.yml
generated
vendored
22
vendor/github.com/gofrs/uuid/.travis.yml
generated
vendored
@ -1,22 +0,0 @@
|
|||||||
language: go
|
|
||||||
sudo: false
|
|
||||||
go:
|
|
||||||
- 1.7.x
|
|
||||||
- 1.8.x
|
|
||||||
- 1.9.x
|
|
||||||
- 1.10.x
|
|
||||||
- 1.11.x
|
|
||||||
- 1.12.x
|
|
||||||
- tip
|
|
||||||
matrix:
|
|
||||||
allow_failures:
|
|
||||||
- go: tip
|
|
||||||
fast_finish: true
|
|
||||||
before_install:
|
|
||||||
- go get golang.org/x/tools/cmd/cover
|
|
||||||
script:
|
|
||||||
- go test ./... -race -coverprofile=coverage.txt -covermode=atomic
|
|
||||||
after_success:
|
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
|
||||||
notifications:
|
|
||||||
email: false
|
|
9
vendor/github.com/gofrs/uuid/README.md
generated
vendored
9
vendor/github.com/gofrs/uuid/README.md
generated
vendored
@ -16,6 +16,14 @@ This package supports the following UUID versions:
|
|||||||
* Version 4, based on random numbers (RFC-4122)
|
* Version 4, based on random numbers (RFC-4122)
|
||||||
* Version 5, based on SHA-1 hashing of a named value (RFC-4122)
|
* Version 5, based on SHA-1 hashing of a named value (RFC-4122)
|
||||||
|
|
||||||
|
This package also supports experimental Universally Unique Identifier implementations based on a
|
||||||
|
[draft RFC](https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html) that updates RFC-4122
|
||||||
|
* Version 6, a k-sortable id based on timestamp, and field-compatible with v1 (draft-peabody-dispatch-new-uuid-format, RFC-4122)
|
||||||
|
* Version 7, a k-sortable id based on timestamp (draft-peabody-dispatch-new-uuid-format, RFC-4122)
|
||||||
|
|
||||||
|
The v6 and v7 IDs are **not** considered a part of the stable API, and may be subject to behavior or API changes as part of minor releases
|
||||||
|
to this package. They will be updated as the draft RFC changes, and will become stable if and when the draft RFC is accepted.
|
||||||
|
|
||||||
## Project History
|
## Project History
|
||||||
|
|
||||||
This project was originally forked from the
|
This project was originally forked from the
|
||||||
@ -106,3 +114,4 @@ func main() {
|
|||||||
|
|
||||||
* [RFC-4122](https://tools.ietf.org/html/rfc4122)
|
* [RFC-4122](https://tools.ietf.org/html/rfc4122)
|
||||||
* [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01)
|
* [DCE 1.1: Authentication and Security Services](http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01)
|
||||||
|
* [New UUID Formats RFC Draft (Peabody) Rev 04](https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#)
|
||||||
|
244
vendor/github.com/gofrs/uuid/codec.go
generated
vendored
244
vendor/github.com/gofrs/uuid/codec.go
generated
vendored
@ -22,8 +22,7 @@
|
|||||||
package uuid
|
package uuid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"errors"
|
||||||
"encoding/hex"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,11 +44,77 @@ func FromBytesOrNil(input []byte) UUID {
|
|||||||
return uuid
|
return uuid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errInvalidFormat = errors.New("uuid: invalid UUID format")
|
||||||
|
|
||||||
|
func fromHexChar(c byte) byte {
|
||||||
|
switch {
|
||||||
|
case '0' <= c && c <= '9':
|
||||||
|
return c - '0'
|
||||||
|
case 'a' <= c && c <= 'f':
|
||||||
|
return c - 'a' + 10
|
||||||
|
case 'A' <= c && c <= 'F':
|
||||||
|
return c - 'A' + 10
|
||||||
|
}
|
||||||
|
return 255
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse parses the UUID stored in the string text. Parsing and supported
|
||||||
|
// formats are the same as UnmarshalText.
|
||||||
|
func (u *UUID) Parse(s string) error {
|
||||||
|
switch len(s) {
|
||||||
|
case 32: // hash
|
||||||
|
case 36: // canonical
|
||||||
|
case 34, 38:
|
||||||
|
if s[0] != '{' || s[len(s)-1] != '}' {
|
||||||
|
return fmt.Errorf("uuid: incorrect UUID format in string %q", s)
|
||||||
|
}
|
||||||
|
s = s[1 : len(s)-1]
|
||||||
|
case 41, 45:
|
||||||
|
if s[:9] != "urn:uuid:" {
|
||||||
|
return fmt.Errorf("uuid: incorrect UUID format in string %q", s[:9])
|
||||||
|
}
|
||||||
|
s = s[9:]
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("uuid: incorrect UUID length %d in string %q", len(s), s)
|
||||||
|
}
|
||||||
|
// canonical
|
||||||
|
if len(s) == 36 {
|
||||||
|
if s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-' {
|
||||||
|
return fmt.Errorf("uuid: incorrect UUID format in string %q", s)
|
||||||
|
}
|
||||||
|
for i, x := range [16]byte{
|
||||||
|
0, 2, 4, 6,
|
||||||
|
9, 11,
|
||||||
|
14, 16,
|
||||||
|
19, 21,
|
||||||
|
24, 26, 28, 30, 32, 34,
|
||||||
|
} {
|
||||||
|
v1 := fromHexChar(s[x])
|
||||||
|
v2 := fromHexChar(s[x+1])
|
||||||
|
if v1|v2 == 255 {
|
||||||
|
return errInvalidFormat
|
||||||
|
}
|
||||||
|
u[i] = (v1 << 4) | v2
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
// hash like
|
||||||
|
for i := 0; i < 32; i += 2 {
|
||||||
|
v1 := fromHexChar(s[i])
|
||||||
|
v2 := fromHexChar(s[i+1])
|
||||||
|
if v1|v2 == 255 {
|
||||||
|
return errInvalidFormat
|
||||||
|
}
|
||||||
|
u[i/2] = (v1 << 4) | v2
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// FromString returns a UUID parsed from the input string.
|
// FromString returns a UUID parsed from the input string.
|
||||||
// Input is expected in a form accepted by UnmarshalText.
|
// Input is expected in a form accepted by UnmarshalText.
|
||||||
func FromString(input string) (UUID, error) {
|
func FromString(text string) (UUID, error) {
|
||||||
u := UUID{}
|
var u UUID
|
||||||
err := u.UnmarshalText([]byte(input))
|
err := u.Parse(text)
|
||||||
return u, err
|
return u, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,135 +131,92 @@ func FromStringOrNil(input string) UUID {
|
|||||||
// MarshalText implements the encoding.TextMarshaler interface.
|
// MarshalText implements the encoding.TextMarshaler interface.
|
||||||
// The encoding is the same as returned by the String() method.
|
// The encoding is the same as returned by the String() method.
|
||||||
func (u UUID) MarshalText() ([]byte, error) {
|
func (u UUID) MarshalText() ([]byte, error) {
|
||||||
return []byte(u.String()), nil
|
var buf [36]byte
|
||||||
|
encodeCanonical(buf[:], u)
|
||||||
|
return buf[:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalText implements the encoding.TextUnmarshaler interface.
|
// UnmarshalText implements the encoding.TextUnmarshaler interface.
|
||||||
// Following formats are supported:
|
// Following formats are supported:
|
||||||
//
|
//
|
||||||
// "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
|
// "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
|
||||||
// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
|
// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
|
||||||
// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
|
// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
|
||||||
// "6ba7b8109dad11d180b400c04fd430c8"
|
// "6ba7b8109dad11d180b400c04fd430c8"
|
||||||
// "{6ba7b8109dad11d180b400c04fd430c8}",
|
// "{6ba7b8109dad11d180b400c04fd430c8}",
|
||||||
// "urn:uuid:6ba7b8109dad11d180b400c04fd430c8"
|
// "urn:uuid:6ba7b8109dad11d180b400c04fd430c8"
|
||||||
//
|
//
|
||||||
// ABNF for supported UUID text representation follows:
|
// ABNF for supported UUID text representation follows:
|
||||||
//
|
//
|
||||||
// URN := 'urn'
|
// URN := 'urn'
|
||||||
// UUID-NID := 'uuid'
|
// UUID-NID := 'uuid'
|
||||||
//
|
//
|
||||||
// hexdig := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
|
// hexdig := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
|
||||||
// 'a' | 'b' | 'c' | 'd' | 'e' | 'f' |
|
// 'a' | 'b' | 'c' | 'd' | 'e' | 'f' |
|
||||||
// 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
|
// 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
|
||||||
//
|
//
|
||||||
// hexoct := hexdig hexdig
|
// hexoct := hexdig hexdig
|
||||||
// 2hexoct := hexoct hexoct
|
// 2hexoct := hexoct hexoct
|
||||||
// 4hexoct := 2hexoct 2hexoct
|
// 4hexoct := 2hexoct 2hexoct
|
||||||
// 6hexoct := 4hexoct 2hexoct
|
// 6hexoct := 4hexoct 2hexoct
|
||||||
// 12hexoct := 6hexoct 6hexoct
|
// 12hexoct := 6hexoct 6hexoct
|
||||||
//
|
//
|
||||||
// hashlike := 12hexoct
|
// hashlike := 12hexoct
|
||||||
// canonical := 4hexoct '-' 2hexoct '-' 2hexoct '-' 6hexoct
|
// canonical := 4hexoct '-' 2hexoct '-' 2hexoct '-' 6hexoct
|
||||||
//
|
//
|
||||||
// plain := canonical | hashlike
|
// plain := canonical | hashlike
|
||||||
// uuid := canonical | hashlike | braced | urn
|
// uuid := canonical | hashlike | braced | urn
|
||||||
//
|
//
|
||||||
// braced := '{' plain '}' | '{' hashlike '}'
|
// braced := '{' plain '}' | '{' hashlike '}'
|
||||||
// urn := URN ':' UUID-NID ':' plain
|
// urn := URN ':' UUID-NID ':' plain
|
||||||
//
|
func (u *UUID) UnmarshalText(b []byte) error {
|
||||||
func (u *UUID) UnmarshalText(text []byte) error {
|
switch len(b) {
|
||||||
switch len(text) {
|
case 32: // hash
|
||||||
case 32:
|
case 36: // canonical
|
||||||
return u.decodeHashLike(text)
|
|
||||||
case 34, 38:
|
case 34, 38:
|
||||||
return u.decodeBraced(text)
|
if b[0] != '{' || b[len(b)-1] != '}' {
|
||||||
case 36:
|
return fmt.Errorf("uuid: incorrect UUID format in string %q", b)
|
||||||
return u.decodeCanonical(text)
|
}
|
||||||
|
b = b[1 : len(b)-1]
|
||||||
case 41, 45:
|
case 41, 45:
|
||||||
return u.decodeURN(text)
|
if string(b[:9]) != "urn:uuid:" {
|
||||||
|
return fmt.Errorf("uuid: incorrect UUID format in string %q", b[:9])
|
||||||
|
}
|
||||||
|
b = b[9:]
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("uuid: incorrect UUID length %d in string %q", len(text), text)
|
return fmt.Errorf("uuid: incorrect UUID length %d in string %q", len(b), b)
|
||||||
}
|
}
|
||||||
}
|
if len(b) == 36 {
|
||||||
|
if b[8] != '-' || b[13] != '-' || b[18] != '-' || b[23] != '-' {
|
||||||
// decodeCanonical decodes UUID strings that are formatted as defined in RFC-4122 (section 3):
|
return fmt.Errorf("uuid: incorrect UUID format in string %q", b)
|
||||||
// "6ba7b810-9dad-11d1-80b4-00c04fd430c8".
|
|
||||||
func (u *UUID) decodeCanonical(t []byte) error {
|
|
||||||
if t[8] != '-' || t[13] != '-' || t[18] != '-' || t[23] != '-' {
|
|
||||||
return fmt.Errorf("uuid: incorrect UUID format in string %q", t)
|
|
||||||
}
|
|
||||||
|
|
||||||
src := t
|
|
||||||
dst := u[:]
|
|
||||||
|
|
||||||
for i, byteGroup := range byteGroups {
|
|
||||||
if i > 0 {
|
|
||||||
src = src[1:] // skip dash
|
|
||||||
}
|
}
|
||||||
_, err := hex.Decode(dst[:byteGroup/2], src[:byteGroup])
|
for i, x := range [16]byte{
|
||||||
if err != nil {
|
0, 2, 4, 6,
|
||||||
return err
|
9, 11,
|
||||||
|
14, 16,
|
||||||
|
19, 21,
|
||||||
|
24, 26, 28, 30, 32, 34,
|
||||||
|
} {
|
||||||
|
v1 := fromHexChar(b[x])
|
||||||
|
v2 := fromHexChar(b[x+1])
|
||||||
|
if v1|v2 == 255 {
|
||||||
|
return errInvalidFormat
|
||||||
|
}
|
||||||
|
u[i] = (v1 << 4) | v2
|
||||||
}
|
}
|
||||||
src = src[byteGroup:]
|
return nil
|
||||||
dst = dst[byteGroup/2:]
|
}
|
||||||
|
for i := 0; i < 32; i += 2 {
|
||||||
|
v1 := fromHexChar(b[i])
|
||||||
|
v2 := fromHexChar(b[i+1])
|
||||||
|
if v1|v2 == 255 {
|
||||||
|
return errInvalidFormat
|
||||||
|
}
|
||||||
|
u[i/2] = (v1 << 4) | v2
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// decodeHashLike decodes UUID strings that are using the following format:
|
|
||||||
// "6ba7b8109dad11d180b400c04fd430c8".
|
|
||||||
func (u *UUID) decodeHashLike(t []byte) error {
|
|
||||||
src := t[:]
|
|
||||||
dst := u[:]
|
|
||||||
|
|
||||||
_, err := hex.Decode(dst, src)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// decodeBraced decodes UUID strings that are using the following formats:
|
|
||||||
// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}"
|
|
||||||
// "{6ba7b8109dad11d180b400c04fd430c8}".
|
|
||||||
func (u *UUID) decodeBraced(t []byte) error {
|
|
||||||
l := len(t)
|
|
||||||
|
|
||||||
if t[0] != '{' || t[l-1] != '}' {
|
|
||||||
return fmt.Errorf("uuid: incorrect UUID format in string %q", t)
|
|
||||||
}
|
|
||||||
|
|
||||||
return u.decodePlain(t[1 : l-1])
|
|
||||||
}
|
|
||||||
|
|
||||||
// decodeURN decodes UUID strings that are using the following formats:
|
|
||||||
// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
|
|
||||||
// "urn:uuid:6ba7b8109dad11d180b400c04fd430c8".
|
|
||||||
func (u *UUID) decodeURN(t []byte) error {
|
|
||||||
total := len(t)
|
|
||||||
|
|
||||||
urnUUIDPrefix := t[:9]
|
|
||||||
|
|
||||||
if !bytes.Equal(urnUUIDPrefix, urnPrefix) {
|
|
||||||
return fmt.Errorf("uuid: incorrect UUID format in string %q", t)
|
|
||||||
}
|
|
||||||
|
|
||||||
return u.decodePlain(t[9:total])
|
|
||||||
}
|
|
||||||
|
|
||||||
// decodePlain decodes UUID strings that are using the following formats:
|
|
||||||
// "6ba7b810-9dad-11d1-80b4-00c04fd430c8" or in hash-like format
|
|
||||||
// "6ba7b8109dad11d180b400c04fd430c8".
|
|
||||||
func (u *UUID) decodePlain(t []byte) error {
|
|
||||||
switch len(t) {
|
|
||||||
case 32:
|
|
||||||
return u.decodeHashLike(t)
|
|
||||||
case 36:
|
|
||||||
return u.decodeCanonical(t)
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("uuid: incorrect UUID length %d in string %q", len(t), t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalBinary implements the encoding.BinaryMarshaler interface.
|
// MarshalBinary implements the encoding.BinaryMarshaler interface.
|
||||||
func (u UUID) MarshalBinary() ([]byte, error) {
|
func (u UUID) MarshalBinary() ([]byte, error) {
|
||||||
return u.Bytes(), nil
|
return u.Bytes(), nil
|
||||||
|
11
vendor/github.com/gofrs/uuid/fuzz.go
generated
vendored
11
vendor/github.com/gofrs/uuid/fuzz.go
generated
vendored
@ -19,6 +19,7 @@
|
|||||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
//go:build gofuzz
|
||||||
// +build gofuzz
|
// +build gofuzz
|
||||||
|
|
||||||
package uuid
|
package uuid
|
||||||
@ -27,15 +28,15 @@ package uuid
|
|||||||
//
|
//
|
||||||
// To run:
|
// To run:
|
||||||
//
|
//
|
||||||
// $ go get github.com/dvyukov/go-fuzz/...
|
// $ go get github.com/dvyukov/go-fuzz/...
|
||||||
// $ cd $GOPATH/src/github.com/gofrs/uuid
|
// $ cd $GOPATH/src/github.com/gofrs/uuid
|
||||||
// $ go-fuzz-build github.com/gofrs/uuid
|
// $ go-fuzz-build github.com/gofrs/uuid
|
||||||
// $ go-fuzz -bin=uuid-fuzz.zip -workdir=./testdata
|
// $ go-fuzz -bin=uuid-fuzz.zip -workdir=./testdata
|
||||||
//
|
//
|
||||||
// If you make significant changes to FromString / UnmarshalText and add
|
// If you make significant changes to FromString / UnmarshalText and add
|
||||||
// new cases to fromStringTests (in codec_test.go), please run
|
// new cases to fromStringTests (in codec_test.go), please run
|
||||||
//
|
//
|
||||||
// $ go test -seed_fuzz_corpus
|
// $ go test -seed_fuzz_corpus
|
||||||
//
|
//
|
||||||
// to seed the corpus with the new interesting inputs, then run the fuzzer.
|
// to seed the corpus with the new interesting inputs, then run the fuzzer.
|
||||||
func Fuzz(data []byte) int {
|
func Fuzz(data []byte) int {
|
||||||
|
209
vendor/github.com/gofrs/uuid/generator.go
generated
vendored
209
vendor/github.com/gofrs/uuid/generator.go
generated
vendored
@ -38,7 +38,8 @@ import (
|
|||||||
// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970).
|
// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970).
|
||||||
const epochStart = 122192928000000000
|
const epochStart = 122192928000000000
|
||||||
|
|
||||||
type epochFunc func() time.Time
|
// EpochFunc is the function type used to provide the current time.
|
||||||
|
type EpochFunc func() time.Time
|
||||||
|
|
||||||
// HWAddrFunc is the function type used to provide hardware (MAC) addresses.
|
// HWAddrFunc is the function type used to provide hardware (MAC) addresses.
|
||||||
type HWAddrFunc func() (net.HardwareAddr, error)
|
type HWAddrFunc func() (net.HardwareAddr, error)
|
||||||
@ -66,12 +67,39 @@ func NewV5(ns UUID, name string) UUID {
|
|||||||
return DefaultGenerator.NewV5(ns, name)
|
return DefaultGenerator.NewV5(ns, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewV6 returns a k-sortable UUID based on a timestamp and 48 bits of
|
||||||
|
// pseudorandom data. The timestamp in a V6 UUID is the same as V1, with the bit
|
||||||
|
// order being adjusted to allow the UUID to be k-sortable.
|
||||||
|
//
|
||||||
|
// This is implemented based on revision 03 of the Peabody UUID draft, and may
|
||||||
|
// be subject to change pending further revisions. Until the final specification
|
||||||
|
// revision is finished, changes required to implement updates to the spec will
|
||||||
|
// not be considered a breaking change. They will happen as a minor version
|
||||||
|
// releases until the spec is final.
|
||||||
|
func NewV6() (UUID, error) {
|
||||||
|
return DefaultGenerator.NewV6()
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewV7 returns a k-sortable UUID based on the current millisecond precision
|
||||||
|
// UNIX epoch and 74 bits of pseudorandom data. It supports single-node batch generation (multiple UUIDs in the same timestamp) with a Monotonic Random counter.
|
||||||
|
//
|
||||||
|
// This is implemented based on revision 04 of the Peabody UUID draft, and may
|
||||||
|
// be subject to change pending further revisions. Until the final specification
|
||||||
|
// revision is finished, changes required to implement updates to the spec will
|
||||||
|
// not be considered a breaking change. They will happen as a minor version
|
||||||
|
// releases until the spec is final.
|
||||||
|
func NewV7() (UUID, error) {
|
||||||
|
return DefaultGenerator.NewV7()
|
||||||
|
}
|
||||||
|
|
||||||
// Generator provides an interface for generating UUIDs.
|
// Generator provides an interface for generating UUIDs.
|
||||||
type Generator interface {
|
type Generator interface {
|
||||||
NewV1() (UUID, error)
|
NewV1() (UUID, error)
|
||||||
NewV3(ns UUID, name string) UUID
|
NewV3(ns UUID, name string) UUID
|
||||||
NewV4() (UUID, error)
|
NewV4() (UUID, error)
|
||||||
NewV5(ns UUID, name string) UUID
|
NewV5(ns UUID, name string) UUID
|
||||||
|
NewV6() (UUID, error)
|
||||||
|
NewV7() (UUID, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gen is a reference UUID generator based on the specifications laid out in
|
// Gen is a reference UUID generator based on the specifications laid out in
|
||||||
@ -92,13 +120,16 @@ type Gen struct {
|
|||||||
|
|
||||||
rand io.Reader
|
rand io.Reader
|
||||||
|
|
||||||
epochFunc epochFunc
|
epochFunc EpochFunc
|
||||||
hwAddrFunc HWAddrFunc
|
hwAddrFunc HWAddrFunc
|
||||||
lastTime uint64
|
lastTime uint64
|
||||||
clockSequence uint16
|
clockSequence uint16
|
||||||
hardwareAddr [6]byte
|
hardwareAddr [6]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GenOption is a function type that can be used to configure a Gen generator.
|
||||||
|
type GenOption func(*Gen)
|
||||||
|
|
||||||
// interface check -- build will fail if *Gen doesn't satisfy Generator
|
// interface check -- build will fail if *Gen doesn't satisfy Generator
|
||||||
var _ Generator = (*Gen)(nil)
|
var _ Generator = (*Gen)(nil)
|
||||||
|
|
||||||
@ -120,18 +151,82 @@ func NewGen() *Gen {
|
|||||||
// MAC address being used, you'll need to create a new generator using this
|
// MAC address being used, you'll need to create a new generator using this
|
||||||
// function.
|
// function.
|
||||||
func NewGenWithHWAF(hwaf HWAddrFunc) *Gen {
|
func NewGenWithHWAF(hwaf HWAddrFunc) *Gen {
|
||||||
return &Gen{
|
return NewGenWithOptions(WithHWAddrFunc(hwaf))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGenWithOptions returns a new instance of Gen with the options provided.
|
||||||
|
// Most people should use NewGen() or NewGenWithHWAF() instead.
|
||||||
|
//
|
||||||
|
// To customize the generator, you can pass in one or more GenOption functions.
|
||||||
|
// For example:
|
||||||
|
//
|
||||||
|
// gen := NewGenWithOptions(
|
||||||
|
// WithHWAddrFunc(myHWAddrFunc),
|
||||||
|
// WithEpochFunc(myEpochFunc),
|
||||||
|
// WithRandomReader(myRandomReader),
|
||||||
|
// )
|
||||||
|
//
|
||||||
|
// NewGenWithOptions(WithHWAddrFunc(myHWAddrFunc)) is equivalent to calling
|
||||||
|
// NewGenWithHWAF(myHWAddrFunc)
|
||||||
|
// NewGenWithOptions() is equivalent to calling NewGen()
|
||||||
|
func NewGenWithOptions(opts ...GenOption) *Gen {
|
||||||
|
gen := &Gen{
|
||||||
epochFunc: time.Now,
|
epochFunc: time.Now,
|
||||||
hwAddrFunc: hwaf,
|
hwAddrFunc: defaultHWAddrFunc,
|
||||||
rand: rand.Reader,
|
rand: rand.Reader,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(gen)
|
||||||
|
}
|
||||||
|
|
||||||
|
return gen
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithHWAddrFunc is a GenOption that allows you to provide your own HWAddrFunc
|
||||||
|
// function.
|
||||||
|
// When this option is nil, the defaultHWAddrFunc is used.
|
||||||
|
func WithHWAddrFunc(hwaf HWAddrFunc) GenOption {
|
||||||
|
return func(gen *Gen) {
|
||||||
|
if hwaf == nil {
|
||||||
|
hwaf = defaultHWAddrFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
gen.hwAddrFunc = hwaf
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithEpochFunc is a GenOption that allows you to provide your own EpochFunc
|
||||||
|
// function.
|
||||||
|
// When this option is nil, time.Now is used.
|
||||||
|
func WithEpochFunc(epochf EpochFunc) GenOption {
|
||||||
|
return func(gen *Gen) {
|
||||||
|
if epochf == nil {
|
||||||
|
epochf = time.Now
|
||||||
|
}
|
||||||
|
|
||||||
|
gen.epochFunc = epochf
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithRandomReader is a GenOption that allows you to provide your own random
|
||||||
|
// reader.
|
||||||
|
// When this option is nil, the default rand.Reader is used.
|
||||||
|
func WithRandomReader(reader io.Reader) GenOption {
|
||||||
|
return func(gen *Gen) {
|
||||||
|
if reader == nil {
|
||||||
|
reader = rand.Reader
|
||||||
|
}
|
||||||
|
|
||||||
|
gen.rand = reader
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewV1 returns a UUID based on the current timestamp and MAC address.
|
// NewV1 returns a UUID based on the current timestamp and MAC address.
|
||||||
func (g *Gen) NewV1() (UUID, error) {
|
func (g *Gen) NewV1() (UUID, error) {
|
||||||
u := UUID{}
|
u := UUID{}
|
||||||
|
|
||||||
timeNow, clockSeq, err := g.getClockSequence()
|
timeNow, clockSeq, err := g.getClockSequence(false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Nil, err
|
return Nil, err
|
||||||
}
|
}
|
||||||
@ -182,8 +277,44 @@ func (g *Gen) NewV5(ns UUID, name string) UUID {
|
|||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// getClockSequence returns the epoch and clock sequence.
|
// NewV6 returns a k-sortable UUID based on a timestamp and 48 bits of
|
||||||
func (g *Gen) getClockSequence() (uint64, uint16, error) {
|
// pseudorandom data. The timestamp in a V6 UUID is the same as V1, with the bit
|
||||||
|
// order being adjusted to allow the UUID to be k-sortable.
|
||||||
|
//
|
||||||
|
// This is implemented based on revision 03 of the Peabody UUID draft, and may
|
||||||
|
// be subject to change pending further revisions. Until the final specification
|
||||||
|
// revision is finished, changes required to implement updates to the spec will
|
||||||
|
// not be considered a breaking change. They will happen as a minor version
|
||||||
|
// releases until the spec is final.
|
||||||
|
func (g *Gen) NewV6() (UUID, error) {
|
||||||
|
var u UUID
|
||||||
|
|
||||||
|
if _, err := io.ReadFull(g.rand, u[10:]); err != nil {
|
||||||
|
return Nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
timeNow, clockSeq, err := g.getClockSequence(false)
|
||||||
|
if err != nil {
|
||||||
|
return Nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
binary.BigEndian.PutUint32(u[0:], uint32(timeNow>>28)) // set time_high
|
||||||
|
binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>12)) // set time_mid
|
||||||
|
binary.BigEndian.PutUint16(u[6:], uint16(timeNow&0xfff)) // set time_low (minus four version bits)
|
||||||
|
binary.BigEndian.PutUint16(u[8:], clockSeq&0x3fff) // set clk_seq_hi_res (minus two variant bits)
|
||||||
|
|
||||||
|
u.SetVersion(V6)
|
||||||
|
u.SetVariant(VariantRFC4122)
|
||||||
|
|
||||||
|
return u, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// getClockSequence returns the epoch and clock sequence for V1,V6 and V7 UUIDs.
|
||||||
|
//
|
||||||
|
// When useUnixTSMs is false, it uses the Coordinated Universal Time (UTC) as a count of 100-
|
||||||
|
//
|
||||||
|
// nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to the Christian calendar).
|
||||||
|
func (g *Gen) getClockSequence(useUnixTSMs bool) (uint64, uint16, error) {
|
||||||
var err error
|
var err error
|
||||||
g.clockSequenceOnce.Do(func() {
|
g.clockSequenceOnce.Do(func() {
|
||||||
buf := make([]byte, 2)
|
buf := make([]byte, 2)
|
||||||
@ -199,7 +330,12 @@ func (g *Gen) getClockSequence() (uint64, uint16, error) {
|
|||||||
g.storageMutex.Lock()
|
g.storageMutex.Lock()
|
||||||
defer g.storageMutex.Unlock()
|
defer g.storageMutex.Unlock()
|
||||||
|
|
||||||
timeNow := g.getEpoch()
|
var timeNow uint64
|
||||||
|
if useUnixTSMs {
|
||||||
|
timeNow = uint64(g.epochFunc().UnixMilli())
|
||||||
|
} else {
|
||||||
|
timeNow = g.getEpoch()
|
||||||
|
}
|
||||||
// Clock didn't change since last UUID generation.
|
// Clock didn't change since last UUID generation.
|
||||||
// Should increase clock sequence.
|
// Should increase clock sequence.
|
||||||
if timeNow <= g.lastTime {
|
if timeNow <= g.lastTime {
|
||||||
@ -210,6 +346,59 @@ func (g *Gen) getClockSequence() (uint64, uint16, error) {
|
|||||||
return timeNow, g.clockSequence, nil
|
return timeNow, g.clockSequence, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewV7 returns a k-sortable UUID based on the current millisecond precision
|
||||||
|
// UNIX epoch and 74 bits of pseudorandom data.
|
||||||
|
//
|
||||||
|
// This is implemented based on revision 04 of the Peabody UUID draft, and may
|
||||||
|
// be subject to change pending further revisions. Until the final specification
|
||||||
|
// revision is finished, changes required to implement updates to the spec will
|
||||||
|
// not be considered a breaking change. They will happen as a minor version
|
||||||
|
// releases until the spec is final.
|
||||||
|
func (g *Gen) NewV7() (UUID, error) {
|
||||||
|
var u UUID
|
||||||
|
/* https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#name-uuid-version-7
|
||||||
|
0 1 2 3
|
||||||
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| unix_ts_ms |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| unix_ts_ms | ver | rand_a |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
|var| rand_b |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
||||||
|
| rand_b |
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */
|
||||||
|
|
||||||
|
ms, clockSeq, err := g.getClockSequence(true)
|
||||||
|
if err != nil {
|
||||||
|
return Nil, err
|
||||||
|
}
|
||||||
|
//UUIDv7 features a 48 bit timestamp. First 32bit (4bytes) represents seconds since 1970, followed by 2 bytes for the ms granularity.
|
||||||
|
u[0] = byte(ms >> 40) //1-6 bytes: big-endian unsigned number of Unix epoch timestamp
|
||||||
|
u[1] = byte(ms >> 32)
|
||||||
|
u[2] = byte(ms >> 24)
|
||||||
|
u[3] = byte(ms >> 16)
|
||||||
|
u[4] = byte(ms >> 8)
|
||||||
|
u[5] = byte(ms)
|
||||||
|
|
||||||
|
//support batching by using a monotonic pseudo-random sequence
|
||||||
|
//The 6th byte contains the version and partially rand_a data.
|
||||||
|
//We will lose the most significant bites from the clockSeq (with SetVersion), but it is ok, we need the least significant that contains the counter to ensure the monotonic property
|
||||||
|
binary.BigEndian.PutUint16(u[6:8], clockSeq) // set rand_a with clock seq which is random and monotonic
|
||||||
|
|
||||||
|
//override first 4bits of u[6].
|
||||||
|
u.SetVersion(V7)
|
||||||
|
|
||||||
|
//set rand_b 64bits of pseudo-random bits (first 2 will be overridden)
|
||||||
|
if _, err = io.ReadFull(g.rand, u[8:16]); err != nil {
|
||||||
|
return Nil, err
|
||||||
|
}
|
||||||
|
//override first 2 bits of byte[8] for the variant
|
||||||
|
u.SetVariant(VariantRFC4122)
|
||||||
|
|
||||||
|
return u, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the hardware address.
|
// Returns the hardware address.
|
||||||
func (g *Gen) getHardwareAddr() ([]byte, error) {
|
func (g *Gen) getHardwareAddr() ([]byte, error) {
|
||||||
var err error
|
var err error
|
||||||
@ -250,9 +439,11 @@ func newFromHash(h hash.Hash, ns UUID, name string) UUID {
|
|||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var netInterfaces = net.Interfaces
|
||||||
|
|
||||||
// Returns the hardware address.
|
// Returns the hardware address.
|
||||||
func defaultHWAddrFunc() (net.HardwareAddr, error) {
|
func defaultHWAddrFunc() (net.HardwareAddr, error) {
|
||||||
ifaces, err := net.Interfaces()
|
ifaces, err := netInterfaces()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []byte{}, err
|
return []byte{}, err
|
||||||
}
|
}
|
||||||
|
35
vendor/github.com/gofrs/uuid/sql.go
generated
vendored
35
vendor/github.com/gofrs/uuid/sql.go
generated
vendored
@ -22,12 +22,14 @@
|
|||||||
package uuid
|
package uuid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"database/sql"
|
||||||
"database/sql/driver"
|
"database/sql/driver"
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var _ driver.Valuer = UUID{}
|
||||||
|
var _ sql.Scanner = (*UUID)(nil)
|
||||||
|
|
||||||
// Value implements the driver.Valuer interface.
|
// Value implements the driver.Valuer interface.
|
||||||
func (u UUID) Value() (driver.Value, error) {
|
func (u UUID) Value() (driver.Value, error) {
|
||||||
return u.String(), nil
|
return u.String(), nil
|
||||||
@ -49,7 +51,9 @@ func (u *UUID) Scan(src interface{}) error {
|
|||||||
return u.UnmarshalText(src)
|
return u.UnmarshalText(src)
|
||||||
|
|
||||||
case string:
|
case string:
|
||||||
return u.UnmarshalText([]byte(src))
|
uu, err := FromString(src)
|
||||||
|
*u = uu
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("uuid: cannot convert %T to UUID", src)
|
return fmt.Errorf("uuid: cannot convert %T to UUID", src)
|
||||||
@ -83,27 +87,30 @@ func (u *NullUUID) Scan(src interface{}) error {
|
|||||||
return u.UUID.Scan(src)
|
return u.UUID.Scan(src)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var nullJSON = []byte("null")
|
||||||
|
|
||||||
// MarshalJSON marshals the NullUUID as null or the nested UUID
|
// MarshalJSON marshals the NullUUID as null or the nested UUID
|
||||||
func (u NullUUID) MarshalJSON() ([]byte, error) {
|
func (u NullUUID) MarshalJSON() ([]byte, error) {
|
||||||
if !u.Valid {
|
if !u.Valid {
|
||||||
return json.Marshal(nil)
|
return nullJSON, nil
|
||||||
}
|
}
|
||||||
|
var buf [38]byte
|
||||||
return json.Marshal(u.UUID)
|
buf[0] = '"'
|
||||||
|
encodeCanonical(buf[1:37], u.UUID)
|
||||||
|
buf[37] = '"'
|
||||||
|
return buf[:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON unmarshals a NullUUID
|
// UnmarshalJSON unmarshals a NullUUID
|
||||||
func (u *NullUUID) UnmarshalJSON(b []byte) error {
|
func (u *NullUUID) UnmarshalJSON(b []byte) error {
|
||||||
if bytes.Equal(b, []byte("null")) {
|
if string(b) == "null" {
|
||||||
u.UUID, u.Valid = Nil, false
|
u.UUID, u.Valid = Nil, false
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if n := len(b); n >= 2 && b[0] == '"' {
|
||||||
if err := json.Unmarshal(b, &u.UUID); err != nil {
|
b = b[1 : n-1]
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
err := u.UUID.UnmarshalText(b)
|
||||||
u.Valid = true
|
u.Valid = (err == nil)
|
||||||
|
return err
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
143
vendor/github.com/gofrs/uuid/uuid.go
generated
vendored
143
vendor/github.com/gofrs/uuid/uuid.go
generated
vendored
@ -20,11 +20,13 @@
|
|||||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
// Package uuid provides implementations of the Universally Unique Identifier
|
// Package uuid provides implementations of the Universally Unique Identifier
|
||||||
// (UUID), as specified in RFC-4122,
|
// (UUID), as specified in RFC-4122 and the Peabody RFC Draft (revision 03).
|
||||||
//
|
//
|
||||||
// RFC-4122[1] provides the specification for versions 1, 3, 4, and 5.
|
// RFC-4122[1] provides the specification for versions 1, 3, 4, and 5. The
|
||||||
|
// Peabody UUID RFC Draft[2] provides the specification for the new k-sortable
|
||||||
|
// UUIDs, versions 6 and 7.
|
||||||
//
|
//
|
||||||
// DCE 1.1[2] provides the specification for version 2, but version 2 support
|
// DCE 1.1[3] provides the specification for version 2, but version 2 support
|
||||||
// was removed from this package in v4 due to some concerns with the
|
// was removed from this package in v4 due to some concerns with the
|
||||||
// specification itself. Reading the spec, it seems that it would result in
|
// specification itself. Reading the spec, it seems that it would result in
|
||||||
// generating UUIDs that aren't very unique. In having read the spec it seemed
|
// generating UUIDs that aren't very unique. In having read the spec it seemed
|
||||||
@ -34,15 +36,14 @@
|
|||||||
// ensure we were understanding the specification correctly.
|
// ensure we were understanding the specification correctly.
|
||||||
//
|
//
|
||||||
// [1] https://tools.ietf.org/html/rfc4122
|
// [1] https://tools.ietf.org/html/rfc4122
|
||||||
// [2] http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01
|
// [2] https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format-03
|
||||||
|
// [3] http://pubs.opengroup.org/onlinepubs/9696989899/chap5.htm#tagcjh_08_02_01_01
|
||||||
package uuid
|
package uuid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -60,6 +61,9 @@ const (
|
|||||||
V3 // Version 3 (namespace name-based)
|
V3 // Version 3 (namespace name-based)
|
||||||
V4 // Version 4 (random)
|
V4 // Version 4 (random)
|
||||||
V5 // Version 5 (namespace name-based)
|
V5 // Version 5 (namespace name-based)
|
||||||
|
V6 // Version 6 (k-sortable timestamp and random data, field-compatible with v1) [peabody draft]
|
||||||
|
V7 // Version 7 (k-sortable timestamp and random data) [peabody draft]
|
||||||
|
_ // Version 8 (k-sortable timestamp, meant for custom implementations) [peabody draft] [not implemented]
|
||||||
)
|
)
|
||||||
|
|
||||||
// UUID layout variants.
|
// UUID layout variants.
|
||||||
@ -88,6 +92,7 @@ const _100nsPerSecond = 10000000
|
|||||||
func (t Timestamp) Time() (time.Time, error) {
|
func (t Timestamp) Time() (time.Time, error) {
|
||||||
secs := uint64(t) / _100nsPerSecond
|
secs := uint64(t) / _100nsPerSecond
|
||||||
nsecs := 100 * (uint64(t) % _100nsPerSecond)
|
nsecs := 100 * (uint64(t) % _100nsPerSecond)
|
||||||
|
|
||||||
return time.Unix(int64(secs)-(epochStart/_100nsPerSecond), int64(nsecs)), nil
|
return time.Unix(int64(secs)-(epochStart/_100nsPerSecond), int64(nsecs)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,17 +103,33 @@ func TimestampFromV1(u UUID) (Timestamp, error) {
|
|||||||
err := fmt.Errorf("uuid: %s is version %d, not version 1", u, u.Version())
|
err := fmt.Errorf("uuid: %s is version %d, not version 1", u, u.Version())
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
low := binary.BigEndian.Uint32(u[0:4])
|
low := binary.BigEndian.Uint32(u[0:4])
|
||||||
mid := binary.BigEndian.Uint16(u[4:6])
|
mid := binary.BigEndian.Uint16(u[4:6])
|
||||||
hi := binary.BigEndian.Uint16(u[6:8]) & 0xfff
|
hi := binary.BigEndian.Uint16(u[6:8]) & 0xfff
|
||||||
|
|
||||||
return Timestamp(uint64(low) + (uint64(mid) << 32) + (uint64(hi) << 48)), nil
|
return Timestamp(uint64(low) + (uint64(mid) << 32) + (uint64(hi) << 48)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// String parse helpers.
|
// TimestampFromV6 returns the Timestamp embedded within a V6 UUID. This
|
||||||
var (
|
// function returns an error if the UUID is any version other than 6.
|
||||||
urnPrefix = []byte("urn:uuid:")
|
//
|
||||||
byteGroups = []int{8, 4, 4, 4, 12}
|
// This is implemented based on revision 03 of the Peabody UUID draft, and may
|
||||||
)
|
// be subject to change pending further revisions. Until the final specification
|
||||||
|
// revision is finished, changes required to implement updates to the spec will
|
||||||
|
// not be considered a breaking change. They will happen as a minor version
|
||||||
|
// releases until the spec is final.
|
||||||
|
func TimestampFromV6(u UUID) (Timestamp, error) {
|
||||||
|
if u.Version() != 6 {
|
||||||
|
return 0, fmt.Errorf("uuid: %s is version %d, not version 6", u, u.Version())
|
||||||
|
}
|
||||||
|
|
||||||
|
hi := binary.BigEndian.Uint32(u[0:4])
|
||||||
|
mid := binary.BigEndian.Uint16(u[4:6])
|
||||||
|
low := binary.BigEndian.Uint16(u[6:8]) & 0xfff
|
||||||
|
|
||||||
|
return Timestamp(uint64(low) + (uint64(mid) << 12) + (uint64(hi) << 28)), nil
|
||||||
|
}
|
||||||
|
|
||||||
// Nil is the nil UUID, as specified in RFC-4122, that has all 128 bits set to
|
// Nil is the nil UUID, as specified in RFC-4122, that has all 128 bits set to
|
||||||
// zero.
|
// zero.
|
||||||
@ -122,6 +143,11 @@ var (
|
|||||||
NamespaceX500 = Must(FromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8"))
|
NamespaceX500 = Must(FromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8"))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// IsNil returns if the UUID is equal to the nil UUID
|
||||||
|
func (u UUID) IsNil() bool {
|
||||||
|
return u == Nil
|
||||||
|
}
|
||||||
|
|
||||||
// Version returns the algorithm version used to generate the UUID.
|
// Version returns the algorithm version used to generate the UUID.
|
||||||
func (u UUID) Version() byte {
|
func (u UUID) Version() byte {
|
||||||
return u[6] >> 4
|
return u[6] >> 4
|
||||||
@ -148,22 +174,33 @@ func (u UUID) Bytes() []byte {
|
|||||||
return u[:]
|
return u[:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// encodeCanonical encodes the canonical RFC-4122 form of UUID u into the
|
||||||
|
// first 36 bytes dst.
|
||||||
|
func encodeCanonical(dst []byte, u UUID) {
|
||||||
|
const hextable = "0123456789abcdef"
|
||||||
|
dst[8] = '-'
|
||||||
|
dst[13] = '-'
|
||||||
|
dst[18] = '-'
|
||||||
|
dst[23] = '-'
|
||||||
|
for i, x := range [16]byte{
|
||||||
|
0, 2, 4, 6,
|
||||||
|
9, 11,
|
||||||
|
14, 16,
|
||||||
|
19, 21,
|
||||||
|
24, 26, 28, 30, 32, 34,
|
||||||
|
} {
|
||||||
|
c := u[i]
|
||||||
|
dst[x] = hextable[c>>4]
|
||||||
|
dst[x+1] = hextable[c&0x0f]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// String returns a canonical RFC-4122 string representation of the UUID:
|
// String returns a canonical RFC-4122 string representation of the UUID:
|
||||||
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
|
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
|
||||||
func (u UUID) String() string {
|
func (u UUID) String() string {
|
||||||
buf := make([]byte, 36)
|
var buf [36]byte
|
||||||
|
encodeCanonical(buf[:], u)
|
||||||
hex.Encode(buf[0:8], u[0:4])
|
return string(buf[:])
|
||||||
buf[8] = '-'
|
|
||||||
hex.Encode(buf[9:13], u[4:6])
|
|
||||||
buf[13] = '-'
|
|
||||||
hex.Encode(buf[14:18], u[6:8])
|
|
||||||
buf[18] = '-'
|
|
||||||
hex.Encode(buf[19:23], u[8:10])
|
|
||||||
buf[23] = '-'
|
|
||||||
hex.Encode(buf[24:], u[10:])
|
|
||||||
|
|
||||||
return string(buf)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format implements fmt.Formatter for UUID values.
|
// Format implements fmt.Formatter for UUID values.
|
||||||
@ -176,52 +213,41 @@ func (u UUID) String() string {
|
|||||||
// All other verbs not handled directly by the fmt package (like '%p') are unsupported and will return
|
// All other verbs not handled directly by the fmt package (like '%p') are unsupported and will return
|
||||||
// "%!verb(uuid.UUID=value)" as recommended by the fmt package.
|
// "%!verb(uuid.UUID=value)" as recommended by the fmt package.
|
||||||
func (u UUID) Format(f fmt.State, c rune) {
|
func (u UUID) Format(f fmt.State, c rune) {
|
||||||
|
if c == 'v' && f.Flag('#') {
|
||||||
|
fmt.Fprintf(f, "%#v", [Size]byte(u))
|
||||||
|
return
|
||||||
|
}
|
||||||
switch c {
|
switch c {
|
||||||
case 'x', 'X':
|
case 'x', 'X':
|
||||||
s := hex.EncodeToString(u.Bytes())
|
b := make([]byte, 32)
|
||||||
|
hex.Encode(b, u[:])
|
||||||
if c == 'X' {
|
if c == 'X' {
|
||||||
s = strings.Map(toCapitalHexDigits, s)
|
toUpperHex(b)
|
||||||
}
|
}
|
||||||
_, _ = io.WriteString(f, s)
|
_, _ = f.Write(b)
|
||||||
case 'v':
|
case 'v', 's', 'S':
|
||||||
var s string
|
b, _ := u.MarshalText()
|
||||||
if f.Flag('#') {
|
|
||||||
s = fmt.Sprintf("%#v", [Size]byte(u))
|
|
||||||
} else {
|
|
||||||
s = u.String()
|
|
||||||
}
|
|
||||||
_, _ = io.WriteString(f, s)
|
|
||||||
case 's', 'S':
|
|
||||||
s := u.String()
|
|
||||||
if c == 'S' {
|
if c == 'S' {
|
||||||
s = strings.Map(toCapitalHexDigits, s)
|
toUpperHex(b)
|
||||||
}
|
}
|
||||||
_, _ = io.WriteString(f, s)
|
_, _ = f.Write(b)
|
||||||
case 'q':
|
case 'q':
|
||||||
_, _ = io.WriteString(f, `"`+u.String()+`"`)
|
b := make([]byte, 38)
|
||||||
|
b[0] = '"'
|
||||||
|
encodeCanonical(b[1:], u)
|
||||||
|
b[37] = '"'
|
||||||
|
_, _ = f.Write(b)
|
||||||
default:
|
default:
|
||||||
// invalid/unsupported format verb
|
// invalid/unsupported format verb
|
||||||
fmt.Fprintf(f, "%%!%c(uuid.UUID=%s)", c, u.String())
|
fmt.Fprintf(f, "%%!%c(uuid.UUID=%s)", c, u.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func toCapitalHexDigits(ch rune) rune {
|
func toUpperHex(b []byte) {
|
||||||
// convert a-f hex digits to A-F
|
for i, c := range b {
|
||||||
switch ch {
|
if 'a' <= c && c <= 'f' {
|
||||||
case 'a':
|
b[i] = c - ('a' - 'A')
|
||||||
return 'A'
|
}
|
||||||
case 'b':
|
|
||||||
return 'B'
|
|
||||||
case 'c':
|
|
||||||
return 'C'
|
|
||||||
case 'd':
|
|
||||||
return 'D'
|
|
||||||
case 'e':
|
|
||||||
return 'E'
|
|
||||||
case 'f':
|
|
||||||
return 'F'
|
|
||||||
default:
|
|
||||||
return ch
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,7 +275,8 @@ func (u *UUID) SetVariant(v byte) {
|
|||||||
// Must is a helper that wraps a call to a function returning (UUID, error)
|
// Must is a helper that wraps a call to a function returning (UUID, error)
|
||||||
// and panics if the error is non-nil. It is intended for use in variable
|
// and panics if the error is non-nil. It is intended for use in variable
|
||||||
// initializations such as
|
// initializations such as
|
||||||
// var packageUUID = uuid.Must(uuid.FromString("123e4567-e89b-12d3-a456-426655440000"))
|
//
|
||||||
|
// var packageUUID = uuid.Must(uuid.FromString("123e4567-e89b-12d3-a456-426655440000"))
|
||||||
func Must(u UUID, err error) UUID {
|
func Must(u UUID, err error) UUID {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -243,7 +243,7 @@ github.com/go-task/slim-sprig
|
|||||||
# github.com/godbus/dbus/v5 v5.0.6
|
# github.com/godbus/dbus/v5 v5.0.6
|
||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
github.com/godbus/dbus/v5
|
github.com/godbus/dbus/v5
|
||||||
# github.com/gofrs/uuid v4.0.0+incompatible
|
# github.com/gofrs/uuid v4.4.0+incompatible
|
||||||
## explicit
|
## explicit
|
||||||
github.com/gofrs/uuid
|
github.com/gofrs/uuid
|
||||||
# github.com/gogo/protobuf v1.3.2
|
# github.com/gogo/protobuf v1.3.2
|
||||||
|
Loading…
Reference in New Issue
Block a user