summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2018-01-03 14:48:20 -0700
committerSteve Manuel <nilslice@gmail.com>2018-01-03 14:48:20 -0700
commit3c8d90cf0d5e2af0a9a6adf508fffda7d636b9a6 (patch)
tree4eb1e31262907a029863a13e6fe93d89a0d0b1a8
parent7b4ce4d9df4768c9bc21dabe988d1287314b9449 (diff)
parent62e38de4b127d75093afb646227ff42575228f3d (diff)
Merge branch 'ponzu-dev' of https://github.com/ponzu-cms/ponzu into ponzu-dev
-rw-r--r--cmd/ponzu/vendor/github.com/satori/go.uuid/.travis.yml2
-rw-r--r--cmd/ponzu/vendor/github.com/satori/go.uuid/LICENSE2
-rw-r--r--cmd/ponzu/vendor/github.com/satori/go.uuid/README.md19
-rw-r--r--cmd/ponzu/vendor/github.com/satori/go.uuid/benchmarks_test.go123
-rw-r--r--cmd/ponzu/vendor/github.com/satori/go.uuid/codec.go206
-rw-r--r--cmd/ponzu/vendor/github.com/satori/go.uuid/codec_test.go251
-rw-r--r--cmd/ponzu/vendor/github.com/satori/go.uuid/generator.go265
-rw-r--r--cmd/ponzu/vendor/github.com/satori/go.uuid/generator_test.go224
-rw-r--r--cmd/ponzu/vendor/github.com/satori/go.uuid/sql.go78
-rw-r--r--cmd/ponzu/vendor/github.com/satori/go.uuid/sql_test.go136
-rw-r--r--cmd/ponzu/vendor/github.com/satori/go.uuid/uuid.go434
-rw-r--r--cmd/ponzu/vendor/github.com/satori/go.uuid/uuid_test.go621
-rw-r--r--system/db/content.go6
-rw-r--r--system/db/upload.go7
14 files changed, 1289 insertions, 1085 deletions
diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/.travis.yml b/cmd/ponzu/vendor/github.com/satori/go.uuid/.travis.yml
index bf90ad5..20dd53b 100644
--- a/cmd/ponzu/vendor/github.com/satori/go.uuid/.travis.yml
+++ b/cmd/ponzu/vendor/github.com/satori/go.uuid/.travis.yml
@@ -7,6 +7,8 @@ go:
- 1.5
- 1.6
- 1.7
+ - 1.8
+ - 1.9
- tip
matrix:
allow_failures:
diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/LICENSE b/cmd/ponzu/vendor/github.com/satori/go.uuid/LICENSE
index 488357b..926d549 100644
--- a/cmd/ponzu/vendor/github.com/satori/go.uuid/LICENSE
+++ b/cmd/ponzu/vendor/github.com/satori/go.uuid/LICENSE
@@ -1,4 +1,4 @@
-Copyright (C) 2013-2016 by Maxim Bublis <b@codemonkey.ru>
+Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/README.md b/cmd/ponzu/vendor/github.com/satori/go.uuid/README.md
index b6aad1c..7702849 100644
--- a/cmd/ponzu/vendor/github.com/satori/go.uuid/README.md
+++ b/cmd/ponzu/vendor/github.com/satori/go.uuid/README.md
@@ -1,8 +1,8 @@
# UUID package for Go language
-[![Build Status](https://travis-ci.org/satori/go.uuid.png?branch=master)](https://travis-ci.org/satori/go.uuid)
+[![Build Status](https://travis-ci.org/satori/go.uuid.svg?branch=master)](https://travis-ci.org/satori/go.uuid)
[![Coverage Status](https://coveralls.io/repos/github/satori/go.uuid/badge.svg?branch=master)](https://coveralls.io/github/satori/go.uuid)
-[![GoDoc](http://godoc.org/github.com/satori/go.uuid?status.png)](http://godoc.org/github.com/satori/go.uuid)
+[![GoDoc](http://godoc.org/github.com/satori/go.uuid?status.svg)](http://godoc.org/github.com/satori/go.uuid)
This package provides pure Go implementation of Universally Unique Identifier (UUID). Supported both creation and parsing of UUIDs.
@@ -37,13 +37,22 @@ import (
func main() {
// Creating UUID Version 4
- u1 := uuid.NewV4()
+ // panic on error
+ u1 := uuid.Must(uuid.NewV4())
fmt.Printf("UUIDv4: %s\n", u1)
+ // or error handling
+ u2, err := uuid.NewV4()
+ if err != nil {
+ fmt.Printf("Something went wrong: %s", err)
+ return
+ }
+ fmt.Printf("UUIDv4: %s\n", u2)
+
// Parsing UUID from string input
u2, err := uuid.FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
if err != nil {
- fmt.Printf("Something gone wrong: %s", err)
+ fmt.Printf("Something went wrong: %s", err)
}
fmt.Printf("Successfully parsed: %s", u2)
}
@@ -59,7 +68,7 @@ func main() {
## Copyright
-Copyright (C) 2013-2016 by Maxim Bublis <b@codemonkey.ru>.
+Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>.
UUID package released under MIT License.
See [LICENSE](https://github.com/satori/go.uuid/blob/master/LICENSE) for details.
diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/benchmarks_test.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/benchmarks_test.go
deleted file mode 100644
index c3baeab..0000000
--- a/cmd/ponzu/vendor/github.com/satori/go.uuid/benchmarks_test.go
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright (C) 2013-2015 by Maxim Bublis <b@codemonkey.ru>
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-package uuid
-
-import (
- "testing"
-)
-
-func BenchmarkFromBytes(b *testing.B) {
- bytes := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
- for i := 0; i < b.N; i++ {
- FromBytes(bytes)
- }
-}
-
-func BenchmarkFromString(b *testing.B) {
- s := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
- for i := 0; i < b.N; i++ {
- FromString(s)
- }
-}
-
-func BenchmarkFromStringUrn(b *testing.B) {
- s := "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
- for i := 0; i < b.N; i++ {
- FromString(s)
- }
-}
-
-func BenchmarkFromStringWithBrackets(b *testing.B) {
- s := "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}"
- for i := 0; i < b.N; i++ {
- FromString(s)
- }
-}
-
-func BenchmarkNewV1(b *testing.B) {
- for i := 0; i < b.N; i++ {
- NewV1()
- }
-}
-
-func BenchmarkNewV2(b *testing.B) {
- for i := 0; i < b.N; i++ {
- NewV2(DomainPerson)
- }
-}
-
-func BenchmarkNewV3(b *testing.B) {
- for i := 0; i < b.N; i++ {
- NewV3(NamespaceDNS, "www.example.com")
- }
-}
-
-func BenchmarkNewV4(b *testing.B) {
- for i := 0; i < b.N; i++ {
- NewV4()
- }
-}
-
-func BenchmarkNewV5(b *testing.B) {
- for i := 0; i < b.N; i++ {
- NewV5(NamespaceDNS, "www.example.com")
- }
-}
-
-func BenchmarkMarshalBinary(b *testing.B) {
- u := NewV4()
- for i := 0; i < b.N; i++ {
- u.MarshalBinary()
- }
-}
-
-func BenchmarkMarshalText(b *testing.B) {
- u := NewV4()
- for i := 0; i < b.N; i++ {
- u.MarshalText()
- }
-}
-
-func BenchmarkUnmarshalBinary(b *testing.B) {
- bytes := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
- u := UUID{}
- for i := 0; i < b.N; i++ {
- u.UnmarshalBinary(bytes)
- }
-}
-
-func BenchmarkUnmarshalText(b *testing.B) {
- bytes := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
- u := UUID{}
- for i := 0; i < b.N; i++ {
- u.UnmarshalText(bytes)
- }
-}
-
-var sink string
-
-func BenchmarkMarshalToString(b *testing.B) {
- u := NewV4()
- for i := 0; i < b.N; i++ {
- sink = u.String()
- }
-}
diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/codec.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/codec.go
new file mode 100644
index 0000000..656892c
--- /dev/null
+++ b/cmd/ponzu/vendor/github.com/satori/go.uuid/codec.go
@@ -0,0 +1,206 @@
+// Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+package uuid
+
+import (
+ "bytes"
+ "encoding/hex"
+ "fmt"
+)
+
+// FromBytes returns UUID converted from raw byte slice input.
+// It will return error if the slice isn't 16 bytes long.
+func FromBytes(input []byte) (u UUID, err error) {
+ err = u.UnmarshalBinary(input)
+ return
+}
+
+// FromBytesOrNil returns UUID converted from raw byte slice input.
+// Same behavior as FromBytes, but returns a Nil UUID on error.
+func FromBytesOrNil(input []byte) UUID {
+ uuid, err := FromBytes(input)
+ if err != nil {
+ return Nil
+ }
+ return uuid
+}
+
+// FromString returns UUID parsed from string input.
+// Input is expected in a form accepted by UnmarshalText.
+func FromString(input string) (u UUID, err error) {
+ err = u.UnmarshalText([]byte(input))
+ return
+}
+
+// FromStringOrNil returns UUID parsed from string input.
+// Same behavior as FromString, but returns a Nil UUID on error.
+func FromStringOrNil(input string) UUID {
+ uuid, err := FromString(input)
+ if err != nil {
+ return Nil
+ }
+ return uuid
+}
+
+// MarshalText implements the encoding.TextMarshaler interface.
+// The encoding is the same as returned by String.
+func (u UUID) MarshalText() (text []byte, err error) {
+ text = []byte(u.String())
+ return
+}
+
+// UnmarshalText implements the encoding.TextUnmarshaler interface.
+// Following formats are supported:
+// "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
+// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
+// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
+// "6ba7b8109dad11d180b400c04fd430c8"
+// ABNF for supported UUID text representation follows:
+// uuid := canonical | hashlike | braced | urn
+// plain := canonical | hashlike
+// canonical := 4hexoct '-' 2hexoct '-' 2hexoct '-' 6hexoct
+// hashlike := 12hexoct
+// braced := '{' plain '}'
+// urn := URN ':' UUID-NID ':' plain
+// URN := 'urn'
+// UUID-NID := 'uuid'
+// 12hexoct := 6hexoct 6hexoct
+// 6hexoct := 4hexoct 2hexoct
+// 4hexoct := 2hexoct 2hexoct
+// 2hexoct := hexoct hexoct
+// hexoct := hexdig hexdig
+// hexdig := '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' |
+// 'a' | 'b' | 'c' | 'd' | 'e' | 'f' |
+// 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
+func (u *UUID) UnmarshalText(text []byte) (err error) {
+ switch len(text) {
+ case 32:
+ return u.decodeHashLike(text)
+ case 36:
+ return u.decodeCanonical(text)
+ case 38:
+ return u.decodeBraced(text)
+ case 41:
+ fallthrough
+ case 45:
+ return u.decodeURN(text)
+ default:
+ return fmt.Errorf("uuid: incorrect UUID length: %s", text)
+ }
+}
+
+// decodeCanonical decodes UUID string in format
+// "6ba7b810-9dad-11d1-80b4-00c04fd430c8".
+func (u *UUID) decodeCanonical(t []byte) (err error) {
+ if t[8] != '-' || t[13] != '-' || t[18] != '-' || t[23] != '-' {
+ return fmt.Errorf("uuid: incorrect UUID format %s", 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])
+ if err != nil {
+ return
+ }
+ src = src[byteGroup:]
+ dst = dst[byteGroup/2:]
+ }
+
+ return
+}
+
+// decodeHashLike decodes UUID string in format
+// "6ba7b8109dad11d180b400c04fd430c8".
+func (u *UUID) decodeHashLike(t []byte) (err error) {
+ src := t[:]
+ dst := u[:]
+
+ if _, err = hex.Decode(dst, src); err != nil {
+ return err
+ }
+ return
+}
+
+// decodeBraced decodes UUID string in format
+// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}" or in format
+// "{6ba7b8109dad11d180b400c04fd430c8}".
+func (u *UUID) decodeBraced(t []byte) (err error) {
+ l := len(t)
+
+ if t[0] != '{' || t[l-1] != '}' {
+ return fmt.Errorf("uuid: incorrect UUID format %s", t)
+ }
+
+ return u.decodePlain(t[1 : l-1])
+}
+
+// decodeURN decodes UUID string in format
+// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8" or in format
+// "urn:uuid:6ba7b8109dad11d180b400c04fd430c8".
+func (u *UUID) decodeURN(t []byte) (err error) {
+ total := len(t)
+
+ urn_uuid_prefix := t[:9]
+
+ if !bytes.Equal(urn_uuid_prefix, urnPrefix) {
+ return fmt.Errorf("uuid: incorrect UUID format: %s", t)
+ }
+
+ return u.decodePlain(t[9:total])
+}
+
+// decodePlain decodes UUID string in canonical format
+// "6ba7b810-9dad-11d1-80b4-00c04fd430c8" or in hash-like format
+// "6ba7b8109dad11d180b400c04fd430c8".
+func (u *UUID) decodePlain(t []byte) (err error) {
+ switch len(t) {
+ case 32:
+ return u.decodeHashLike(t)
+ case 36:
+ return u.decodeCanonical(t)
+ default:
+ return fmt.Errorf("uuid: incorrrect UUID length: %s", t)
+ }
+}
+
+// MarshalBinary implements the encoding.BinaryMarshaler interface.
+func (u UUID) MarshalBinary() (data []byte, err error) {
+ data = u.Bytes()
+ return
+}
+
+// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
+// It will return error if the slice isn't 16 bytes long.
+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
+}
diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/codec_test.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/codec_test.go
new file mode 100644
index 0000000..7158c09
--- /dev/null
+++ b/cmd/ponzu/vendor/github.com/satori/go.uuid/codec_test.go
@@ -0,0 +1,251 @@
+// Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+package uuid
+
+import (
+ "bytes"
+
+ . "gopkg.in/check.v1"
+)
+
+type codecTestSuite struct{}
+
+var _ = Suite(&codecTestSuite{})
+
+func (s *codecTestSuite) TestFromBytes(c *C) {
+ u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+ b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+
+ u1, err := FromBytes(b1)
+ c.Assert(err, IsNil)
+ c.Assert(u1, Equals, u)
+
+ b2 := []byte{}
+ _, err = FromBytes(b2)
+ c.Assert(err, NotNil)
+}
+
+func (s *codecTestSuite) BenchmarkFromBytes(c *C) {
+ bytes := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+ for i := 0; i < c.N; i++ {
+ FromBytes(bytes)
+ }
+}
+
+func (s *codecTestSuite) TestMarshalBinary(c *C) {
+ u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+ b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+
+ b2, err := u.MarshalBinary()
+ c.Assert(err, IsNil)
+ c.Assert(bytes.Equal(b1, b2), Equals, true)
+}
+
+func (s *codecTestSuite) BenchmarkMarshalBinary(c *C) {
+ u, err := NewV4()
+ c.Assert(err, IsNil)
+ for i := 0; i < c.N; i++ {
+ u.MarshalBinary()
+ }
+}
+
+func (s *codecTestSuite) TestUnmarshalBinary(c *C) {
+ u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+ b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+
+ u1 := UUID{}
+ err := u1.UnmarshalBinary(b1)
+ c.Assert(err, IsNil)
+ c.Assert(u1, Equals, u)
+
+ b2 := []byte{}
+ u2 := UUID{}
+ err = u2.UnmarshalBinary(b2)
+ c.Assert(err, NotNil)
+}
+
+func (s *codecTestSuite) TestFromString(c *C) {
+ u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+
+ s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
+ s2 := "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}"
+ s3 := "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
+ s4 := "6ba7b8109dad11d180b400c04fd430c8"
+ s5 := "urn:uuid:6ba7b8109dad11d180b400c04fd430c8"
+
+ _, err := FromString("")
+ c.Assert(err, NotNil)
+
+ u1, err := FromString(s1)
+ c.Assert(err, IsNil)
+ c.Assert(u1, Equals, u)
+
+ u2, err := FromString(s2)
+ c.Assert(err, IsNil)
+ c.Assert(u2, Equals, u)
+
+ u3, err := FromString(s3)
+ c.Assert(err, IsNil)
+ c.Assert(u3, Equals, u)
+
+ u4, err := FromString(s4)
+ c.Assert(err, IsNil)
+ c.Assert(u4, Equals, u)
+
+ u5, err := FromString(s5)
+ c.Assert(err, IsNil)
+ c.Assert(u5, Equals, u)
+}
+
+func (s *codecTestSuite) BenchmarkFromString(c *C) {
+ str := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
+ for i := 0; i < c.N; i++ {
+ FromString(str)
+ }
+}
+
+func (s *codecTestSuite) BenchmarkFromStringUrn(c *C) {
+ str := "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
+ for i := 0; i < c.N; i++ {
+ FromString(str)
+ }
+}
+
+func (s *codecTestSuite) BenchmarkFromStringWithBrackets(c *C) {
+ str := "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}"
+ for i := 0; i < c.N; i++ {
+ FromString(str)
+ }
+}
+
+func (s *codecTestSuite) TestFromStringShort(c *C) {
+ // Invalid 35-character UUID string
+ s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c"
+
+ for i := len(s1); i >= 0; i-- {
+ _, err := FromString(s1[:i])
+ c.Assert(err, NotNil)
+ }
+}
+
+func (s *codecTestSuite) TestFromStringLong(c *C) {
+ // Invalid 37+ character UUID string
+ strings := []string{
+ "6ba7b810-9dad-11d1-80b4-00c04fd430c8=",
+ "6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
+ "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}f",
+ "6ba7b810-9dad-11d1-80b4-00c04fd430c800c04fd430c8",
+ }
+
+ for _, str := range strings {
+ _, err := FromString(str)
+ c.Assert(err, NotNil)
+ }
+}
+
+func (s *codecTestSuite) TestFromStringInvalid(c *C) {
+ // Invalid UUID string formats
+ strings := []string{
+ "6ba7b8109dad11d180b400c04fd430c86ba7b8109dad11d180b400c04fd430c8",
+ "urn:uuid:{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
+ "uuid:urn:6ba7b810-9dad-11d1-80b4-00c04fd430c8",
+ "uuid:urn:6ba7b8109dad11d180b400c04fd430c8",
+ "6ba7b8109-dad-11d1-80b4-00c04fd430c8",
+ "6ba7b810-9dad1-1d1-80b4-00c04fd430c8",
+ "6ba7b810-9dad-11d18-0b4-00c04fd430c8",
+ "6ba7b810-9dad-11d1-80b40-0c04fd430c8",
+ "6ba7b810+9dad+11d1+80b4+00c04fd430c8",
+ "(6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
+ "{6ba7b810-9dad-11d1-80b4-00c04fd430c8>",
+ "zba7b810-9dad-11d1-80b4-00c04fd430c8",
+ "6ba7b810-9dad11d180b400c04fd430c8",
+ "6ba7b8109dad-11d180b400c04fd430c8",
+ "6ba7b8109dad11d1-80b400c04fd430c8",
+ "6ba7b8109dad11d180b4-00c04fd430c8",
+ }
+
+ for _, str := range strings {
+ _, err := FromString(str)
+ c.Assert(err, NotNil)
+ }
+}
+
+func (s *codecTestSuite) TestFromStringOrNil(c *C) {
+ u := FromStringOrNil("")
+ c.Assert(u, Equals, Nil)
+}
+
+func (s *codecTestSuite) TestFromBytesOrNil(c *C) {
+ b := []byte{}
+ u := FromBytesOrNil(b)
+ c.Assert(u, Equals, Nil)
+}
+
+func (s *codecTestSuite) TestMarshalText(c *C) {
+ u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+ b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
+
+ b2, err := u.MarshalText()
+ c.Assert(err, IsNil)
+ c.Assert(bytes.Equal(b1, b2), Equals, true)
+}
+
+func (s *codecTestSuite) BenchmarkMarshalText(c *C) {
+ u, err := NewV4()
+ c.Assert(err, IsNil)
+ for i := 0; i < c.N; i++ {
+ u.MarshalText()
+ }
+}
+
+func (s *codecTestSuite) TestUnmarshalText(c *C) {
+ u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+ b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
+
+ u1 := UUID{}
+ err := u1.UnmarshalText(b1)
+ c.Assert(err, IsNil)
+ c.Assert(u1, Equals, u)
+
+ b2 := []byte("")
+ u2 := UUID{}
+ err = u2.UnmarshalText(b2)
+ c.Assert(err, NotNil)
+}
+
+func (s *codecTestSuite) BenchmarkUnmarshalText(c *C) {
+ bytes := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
+ u := UUID{}
+ for i := 0; i < c.N; i++ {
+ u.UnmarshalText(bytes)
+ }
+}
+
+var sink string
+
+func (s *codecTestSuite) BenchmarkMarshalToString(c *C) {
+ u, err := NewV4()
+ c.Assert(err, IsNil)
+ for i := 0; i < c.N; i++ {
+ sink = u.String()
+ }
+}
diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/generator.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/generator.go
new file mode 100644
index 0000000..499dc35
--- /dev/null
+++ b/cmd/ponzu/vendor/github.com/satori/go.uuid/generator.go
@@ -0,0 +1,265 @@
+// Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+package uuid
+
+import (
+ "crypto/md5"
+ "crypto/rand"
+ "crypto/sha1"
+ "encoding/binary"
+ "fmt"
+ "hash"
+ "io"
+ "net"
+ "os"
+ "sync"
+ "time"
+)
+
+// Difference in 100-nanosecond intervals between
+// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970).
+const epochStart = 122192928000000000
+
+type epochFunc func() time.Time
+type hwAddrFunc func() (net.HardwareAddr, error)
+
+var (
+ global = newRFC4122Generator()
+
+ posixUID = uint32(os.Getuid())
+ posixGID = uint32(os.Getgid())
+)
+
+// NewV1 returns UUID based on current timestamp and MAC address.
+func NewV1() (UUID, error) {
+ return global.NewV1()
+}
+
+// NewV2 returns DCE Security UUID based on POSIX UID/GID.
+func NewV2(domain byte) (UUID, error) {
+ return global.NewV2(domain)
+}
+
+// NewV3 returns UUID based on MD5 hash of namespace UUID and name.
+func NewV3(ns UUID, name string) UUID {
+ return global.NewV3(ns, name)
+}
+
+// NewV4 returns random generated UUID.
+func NewV4() (UUID, error) {
+ return global.NewV4()
+}
+
+// NewV5 returns UUID based on SHA-1 hash of namespace UUID and name.
+func NewV5(ns UUID, name string) UUID {
+ return global.NewV5(ns, name)
+}
+
+// Generator provides interface for generating UUIDs.
+type Generator interface {
+ NewV1() (UUID, error)
+ NewV2(domain byte) (UUID, error)
+ NewV3(ns UUID, name string) UUID
+ NewV4() (UUID, error)
+ NewV5(ns UUID, name string) UUID
+}
+
+// Default generator implementation.
+type rfc4122Generator struct {
+ clockSequenceOnce sync.Once
+ hardwareAddrOnce sync.Once
+ storageMutex sync.Mutex
+
+ rand io.Reader
+
+ epochFunc epochFunc
+ hwAddrFunc hwAddrFunc
+ lastTime uint64
+ clockSequence uint16
+ hardwareAddr [6]byte
+}
+
+func newRFC4122Generator() Generator {
+ return &rfc4122Generator{
+ epochFunc: time.Now,
+ hwAddrFunc: defaultHWAddrFunc,
+ rand: rand.Reader,
+ }
+}
+
+// NewV1 returns UUID based on current timestamp and MAC address.
+func (g *rfc4122Generator) NewV1() (UUID, error) {
+ u := UUID{}
+
+ timeNow, clockSeq, err := g.getClockSequence()
+ if err != nil {
+ return Nil, err
+ }
+ 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)
+
+ hardwareAddr, err := g.getHardwareAddr()
+ if err != nil {
+ return Nil, err
+ }
+ copy(u[10:], hardwareAddr)
+
+ u.SetVersion(V1)
+ u.SetVariant(VariantRFC4122)
+
+ return u, nil
+}
+
+// NewV2 returns DCE Security UUID based on POSIX UID/GID.
+func (g *rfc4122Generator) NewV2(domain byte) (UUID, error) {
+ u, err := g.NewV1()
+ if err != nil {
+ return Nil, err
+ }
+
+ switch domain {
+ case DomainPerson:
+ binary.BigEndian.PutUint32(u[:], posixUID)
+ case DomainGroup:
+ binary.BigEndian.PutUint32(u[:], posixGID)
+ }
+
+ u[9] = domain
+
+ u.SetVersion(V2)
+ u.SetVariant(VariantRFC4122)
+
+ return u, nil
+}
+
+// NewV3 returns UUID based on MD5 hash of namespace UUID and name.
+func (g *rfc4122Generator) NewV3(ns UUID, name string) UUID {
+ u := newFromHash(md5.New(), ns, name)
+ u.SetVersion(V3)
+ u.SetVariant(VariantRFC4122)
+
+ return u
+}
+
+// NewV4 returns random generated UUID.
+func (g *rfc4122Generator) NewV4() (UUID, error) {
+ u := UUID{}
+ if _, err := g.rand.Read(u[:]); err != nil {
+ return Nil, err
+ }
+ u.SetVersion(V4)
+ u.SetVariant(VariantRFC4122)
+
+ return u, nil
+}
+
+// NewV5 returns UUID based on SHA-1 hash of namespace UUID and name.
+func (g *rfc4122Generator) NewV5(ns UUID, name string) UUID {
+ u := newFromHash(sha1.New(), ns, name)
+ u.SetVersion(V5)
+ u.SetVariant(VariantRFC4122)
+
+ return u
+}
+
+// Returns epoch and clock sequence.
+func (g *rfc4122Generator) getClockSequence() (uint64, uint16, error) {
+ var err error
+ g.clockSequenceOnce.Do(func() {
+ buf := make([]byte, 2)
+ if _, err = g.rand.Read(buf); err != nil {
+ return
+ }
+ g.clockSequence = binary.BigEndian.Uint16(buf)
+ })
+ if err != nil {
+ return 0, 0, err
+ }
+
+ g.storageMutex.Lock()
+ defer g.storageMutex.Unlock()
+
+ timeNow := g.getEpoch()
+ // Clock didn't change since last UUID generation.
+ // Should increase clock sequence.
+ if timeNow <= g.lastTime {
+ g.clockSequence++
+ }
+ g.lastTime = timeNow
+
+ return timeNow, g.clockSequence, nil
+}
+
+// Returns hardware address.
+func (g *rfc4122Generator) getHardwareAddr() ([]byte, error) {
+ var err error
+ g.hardwareAddrOnce.Do(func() {
+ if hwAddr, err := g.hwAddrFunc(); err == nil {
+ copy(g.hardwareAddr[:], hwAddr)
+ return
+ }
+
+ // Initialize hardwareAddr randomly in case
+ // of real network interfaces absence.
+ if _, err = g.rand.Read(g.hardwareAddr[:]); err != nil {
+ return
+ }
+ // Set multicast bit as recommended by RFC 4122
+ g.hardwareAddr[0] |= 0x01
+ })
+ if err != nil {
+ return []byte{}, err
+ }
+ return g.hardwareAddr[:], nil
+}
+
+// Returns difference in 100-nanosecond intervals between
+// UUID epoch (October 15, 1582) and current time.
+func (g *rfc4122Generator) getEpoch() uint64 {
+ return epochStart + uint64(g.epochFunc().UnixNano()/100)
+}
+
+// Returns UUID based on hashing of namespace UUID and name.
+func newFromHash(h hash.Hash, ns UUID, name string) UUID {
+ u := UUID{}
+ h.Write(ns[:])
+ h.Write([]byte(name))
+ copy(u[:], h.Sum(nil))
+
+ return u
+}
+
+// Returns hardware address.
+func defaultHWAddrFunc() (net.HardwareAddr, error) {
+ ifaces, err := net.Interfaces()
+ if err != nil {
+ return []byte{}, err
+ }
+ for _, iface := range ifaces {
+ if len(iface.HardwareAddr) >= 6 {
+ return iface.HardwareAddr, nil
+ }
+ }
+ return []byte{}, fmt.Errorf("uuid: no HW address found")
+}
diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/generator_test.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/generator_test.go
new file mode 100644
index 0000000..82a236a
--- /dev/null
+++ b/cmd/ponzu/vendor/github.com/satori/go.uuid/generator_test.go
@@ -0,0 +1,224 @@
+// Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+package uuid
+
+import (
+ "crypto/rand"
+ "fmt"
+ "net"
+ "time"
+
+ . "gopkg.in/check.v1"
+)
+
+type faultyReader struct {
+ callsNum int
+ readToFail int // Read call number to fail
+}
+
+func (r *faultyReader) Read(dest []byte) (int, error) {
+ r.callsNum++
+ if (r.callsNum - 1) == r.readToFail {
+ return 0, fmt.Errorf("io: reader is faulty")
+ }
+ return rand.Read(dest)
+}
+
+type genTestSuite struct{}
+
+var _ = Suite(&genTestSuite{})
+
+func (s *genTestSuite) TestNewV1(c *C) {
+ u1, err := NewV1()
+ c.Assert(err, IsNil)
+ c.Assert(u1.Version(), Equals, V1)
+ c.Assert(u1.Variant(), Equals, VariantRFC4122)
+
+ u2, err := NewV1()
+ c.Assert(err, IsNil)
+ c.Assert(u1, Not(Equals), u2)
+}
+
+func (s *genTestSuite) TestNewV1EpochStale(c *C) {
+ g := &rfc4122Generator{
+ epochFunc: func() time.Time {
+ return time.Unix(0, 0)
+ },
+ hwAddrFunc: defaultHWAddrFunc,
+ rand: rand.Reader,
+ }
+ u1, err := g.NewV1()
+ c.Assert(err, IsNil)
+ u2, err := g.NewV1()
+ c.Assert(err, IsNil)
+ c.Assert(u1, Not(Equals), u2)
+}
+
+func (s *genTestSuite) TestNewV1FaultyRand(c *C) {
+ g := &rfc4122Generator{
+ epochFunc: time.Now,
+ hwAddrFunc: defaultHWAddrFunc,
+ rand: &faultyReader{},
+ }
+ u1, err := g.NewV1()
+ c.Assert(err, NotNil)
+ c.Assert(u1, Equals, Nil)
+}
+
+func (s *genTestSuite) TestNewV1MissingNetworkInterfaces(c *C) {
+ g := &rfc4122Generator{
+ epochFunc: time.Now,
+ hwAddrFunc: func() (net.HardwareAddr, error) {
+ return []byte{}, fmt.Errorf("uuid: no hw address found")
+ },
+ rand: rand.Reader,
+ }
+ _, err := g.NewV1()
+ c.Assert(err, IsNil)
+}
+
+func (s *genTestSuite) TestNewV1MissingNetInterfacesAndFaultyRand(c *C) {
+ g := &rfc4122Generator{
+ epochFunc: time.Now,
+ hwAddrFunc: func() (net.HardwareAddr, error) {
+ return []byte{}, fmt.Errorf("uuid: no hw address found")
+ },
+ rand: &faultyReader{
+ readToFail: 1,
+ },
+ }
+ u1, err := g.NewV1()
+ c.Assert(err, NotNil)
+ c.Assert(u1, Equals, Nil)
+}
+
+func (s *genTestSuite) BenchmarkNewV1(c *C) {
+ for i := 0; i < c.N; i++ {
+ NewV1()
+ }
+}
+
+func (s *genTestSuite) TestNewV2(c *C) {
+ u1, err := NewV2(DomainPerson)
+ c.Assert(err, IsNil)
+ c.Assert(u1.Version(), Equals, V2)
+ c.Assert(u1.Variant(), Equals, VariantRFC4122)
+
+ u2, err := NewV2(DomainGroup)
+ c.Assert(err, IsNil)
+ c.Assert(u2.Version(), Equals, V2)
+ c.Assert(u2.Variant(), Equals, VariantRFC4122)
+
+ u3, err := NewV2(DomainOrg)
+ c.Assert(err, IsNil)
+ c.Assert(u3.Version(), Equals, V2)
+ c.Assert(u3.Variant(), Equals, VariantRFC4122)
+}
+
+func (s *genTestSuite) TestNewV2FaultyRand(c *C) {
+ g := &rfc4122Generator{
+ epochFunc: time.Now,
+ hwAddrFunc: defaultHWAddrFunc,
+ rand: &faultyReader{},
+ }
+ u1, err := g.NewV2(DomainPerson)
+ c.Assert(err, NotNil)
+ c.Assert(u1, Equals, Nil)
+}
+
+func (s *genTestSuite) BenchmarkNewV2(c *C) {
+ for i := 0; i < c.N; i++ {
+ NewV2(DomainPerson)
+ }
+}
+
+func (s *genTestSuite) TestNewV3(c *C) {
+ u1 := NewV3(NamespaceDNS, "www.example.com")
+ c.Assert(u1.Version(), Equals, V3)
+ c.Assert(u1.Variant(), Equals, VariantRFC4122)
+ c.Assert(u1.String(), Equals, "5df41881-3aed-3515-88a7-2f4a814cf09e")
+
+ u2 := NewV3(NamespaceDNS, "example.com")
+ c.Assert(u2, Not(Equals), u1)
+
+ u3 := NewV3(NamespaceDNS, "example.com")
+ c.Assert(u3, Equals, u2)
+
+ u4 := NewV3(NamespaceURL, "example.com")
+ c.Assert(u4, Not(Equals), u3)
+}
+
+func (s *genTestSuite) BenchmarkNewV3(c *C) {
+ for i := 0; i < c.N; i++ {
+ NewV3(NamespaceDNS, "www.example.com")
+ }
+}
+
+func (s *genTestSuite) TestNewV4(c *C) {
+ u1, err := NewV4()
+ c.Assert(err, IsNil)
+ c.Assert(u1.Version(), Equals, V4)
+ c.Assert(u1.Variant(), Equals, VariantRFC4122)
+
+ u2, err := NewV4()
+ c.Assert(err, IsNil)
+ c.Assert(u1, Not(Equals), u2)
+}
+
+func (s *genTestSuite) TestNewV4FaultyRand(c *C) {
+ g := &rfc4122Generator{
+ epochFunc: time.Now,
+ hwAddrFunc: defaultHWAddrFunc,
+ rand: &faultyReader{},
+ }
+ u1, err := g.NewV4()
+ c.Assert(err, NotNil)
+ c.Assert(u1, Equals, Nil)
+}
+
+func (s *genTestSuite) BenchmarkNewV4(c *C) {
+ for i := 0; i < c.N; i++ {
+ NewV4()
+ }
+}
+
+func (s *genTestSuite) TestNewV5(c *C) {
+ u1 := NewV5(NamespaceDNS, "www.example.com")
+ c.Assert(u1.Version(), Equals, V5)
+ c.Assert(u1.Variant(), Equals, VariantRFC4122)
+ c.Assert(u1.String(), Equals, "2ed6657d-e927-568b-95e1-2665a8aea6a2")
+
+ u2 := NewV5(NamespaceDNS, "example.com")
+ c.Assert(u2, Not(Equals), u1)
+
+ u3 := NewV5(NamespaceDNS, "example.com")
+ c.Assert(u3, Equals, u2)
+
+ u4 := NewV5(NamespaceURL, "example.com")
+ c.Assert(u4, Not(Equals), u3)
+}
+
+func (s *genTestSuite) BenchmarkNewV5(c *C) {
+ for i := 0; i < c.N; i++ {
+ NewV5(NamespaceDNS, "www.example.com")
+ }
+}
diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/sql.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/sql.go
new file mode 100644
index 0000000..56759d3
--- /dev/null
+++ b/cmd/ponzu/vendor/github.com/satori/go.uuid/sql.go
@@ -0,0 +1,78 @@
+// Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+package uuid
+
+import (
+ "database/sql/driver"
+ "fmt"
+)
+
+// Value implements the driver.Valuer interface.
+func (u UUID) Value() (driver.Value, error) {
+ return u.String(), nil
+}
+
+// Scan implements the sql.Scanner interface.
+// A 16-byte slice is handled by UnmarshalBinary, while
+// a longer byte slice or a string is handled by UnmarshalText.
+func (u *UUID) Scan(src interface{}) error {
+ switch src := src.(type) {
+ case []byte:
+ if len(src) == Size {
+ return u.UnmarshalBinary(src)
+ }
+ return u.UnmarshalText(src)
+
+ case string:
+ return u.UnmarshalText([]byte(src))
+ }
+
+ return fmt.Errorf("uuid: cannot convert %T to UUID", src)
+}
+
+// NullUUID can be used with the standard sql package to represent a
+// UUID value that can be NULL in the database
+type NullUUID struct {
+ UUID UUID
+ Valid bool
+}
+
+// Value implements the driver.Valuer interface.
+func (u NullUUID) Value() (driver.Value, error) {
+ if !u.Valid {
+ return nil, nil
+ }
+ // Delegate to UUID Value function
+ return u.UUID.Value()
+}
+
+// Scan implements the sql.Scanner interface.
+func (u *NullUUID) Scan(src interface{}) error {
+ if src == nil {
+ u.UUID, u.Valid = Nil, false
+ return nil
+ }
+
+ // Delegate to UUID Scan function
+ u.Valid = true
+ return u.UUID.Scan(src)
+}
diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/sql_test.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/sql_test.go
new file mode 100644
index 0000000..74255f5
--- /dev/null
+++ b/cmd/ponzu/vendor/github.com/satori/go.uuid/sql_test.go
@@ -0,0 +1,136 @@
+// Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+package uuid
+
+import (
+ . "gopkg.in/check.v1"
+)
+
+type sqlTestSuite struct{}
+
+var _ = Suite(&sqlTestSuite{})
+
+func (s *sqlTestSuite) TestValue(c *C) {
+ u, err := FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
+ c.Assert(err, IsNil)
+
+ val, err := u.Value()
+ c.Assert(err, IsNil)
+ c.Assert(val, Equals, u.String())
+}
+
+func (s *sqlTestSuite) TestValueNil(c *C) {
+ u := UUID{}
+
+ val, err := u.Value()
+ c.Assert(err, IsNil)
+ c.Assert(val, Equals, Nil.String())
+}
+
+func (s *sqlTestSuite) TestNullUUIDValueNil(c *C) {
+ u := NullUUID{}
+
+ val, err := u.Value()
+ c.Assert(err, IsNil)
+ c.Assert(val, IsNil)
+}
+
+func (s *sqlTestSuite) TestScanBinary(c *C) {
+ u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+ b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+
+ u1 := UUID{}
+ err := u1.Scan(b1)
+ c.Assert(err, IsNil)
+ c.Assert(u, Equals, u1)
+
+ b2 := []byte{}
+ u2 := UUID{}
+
+ err = u2.Scan(b2)
+ c.Assert(err, NotNil)
+}
+
+func (s *sqlTestSuite) TestScanString(c *C) {
+ u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+ s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
+
+ u1 := UUID{}
+ err := u1.Scan(s1)
+ c.Assert(err, IsNil)
+ c.Assert(u, Equals, u1)
+
+ s2 := ""
+ u2 := UUID{}
+
+ err = u2.Scan(s2)
+ c.Assert(err, NotNil)
+}
+
+func (s *sqlTestSuite) TestScanText(c *C) {
+ u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+ b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
+
+ u1 := UUID{}
+ err := u1.Scan(b1)
+ c.Assert(err, IsNil)
+ c.Assert(u, Equals, u1)
+
+ b2 := []byte("")
+ u2 := UUID{}
+ err = u2.Scan(b2)
+ c.Assert(err, NotNil)
+}
+
+func (s *sqlTestSuite) TestScanUnsupported(c *C) {
+ u := UUID{}
+
+ err := u.Scan(true)
+ c.Assert(err, NotNil)
+}
+
+func (s *sqlTestSuite) TestScanNil(c *C) {
+ u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+
+ err := u.Scan(nil)
+ c.Assert(err, NotNil)
+}
+
+func (s *sqlTestSuite) TestNullUUIDScanValid(c *C) {
+ u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+ s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
+
+ u1 := NullUUID{}
+ err := u1.Scan(s1)
+ c.Assert(err, IsNil)
+ c.Assert(u1.Valid, Equals, true)
+ c.Assert(u1.UUID, Equals, u)
+}
+
+func (s *sqlTestSuite) TestNullUUIDScanNil(c *C) {
+ u := NullUUID{UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}, true}
+
+ err := u.Scan(nil)
+ c.Assert(err, IsNil)
+ c.Assert(u.Valid, Equals, false)
+ c.Assert(u.UUID, Equals, Nil)
+}
diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid.go
index 295f3fc..a2b8e2c 100644
--- a/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid.go
+++ b/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid.go
@@ -1,4 +1,4 @@
-// Copyright (C) 2013-2015 by Maxim Bublis <b@codemonkey.ru>
+// Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -26,23 +26,29 @@ package uuid
import (
"bytes"
- "crypto/md5"
- "crypto/rand"
- "crypto/sha1"
- "database/sql/driver"
- "encoding/binary"
"encoding/hex"
- "fmt"
- "hash"
- "net"
- "os"
- "sync"
- "time"
+)
+
+// Size of a UUID in bytes.
+const Size = 16
+
+// UUID representation compliant with specification
+// described in RFC 4122.
+type UUID [Size]byte
+
+// UUID versions
+const (
+ _ byte = iota
+ V1
+ V2
+ V3
+ V4
+ V5
)
// UUID layout variants.
const (
- VariantNCS = iota
+ VariantNCS byte = iota
VariantRFC4122
VariantMicrosoft
VariantFuture
@@ -55,136 +61,48 @@ const (
DomainOrg
)
-// Difference in 100-nanosecond intervals between
-// UUID epoch (October 15, 1582) and Unix epoch (January 1, 1970).
-const epochStart = 122192928000000000
-
-// Used in string method conversion
-const dash byte = '-'
-
-// UUID v1/v2 storage.
-var (
- storageMutex sync.Mutex
- storageOnce sync.Once
- epochFunc = unixTimeFunc
- clockSequence uint16
- lastTime uint64
- hardwareAddr [6]byte
- posixUID = uint32(os.Getuid())
- posixGID = uint32(os.Getgid())
-)
-
// String parse helpers.
var (
urnPrefix = []byte("urn:uuid:")
byteGroups = []int{8, 4, 4, 4, 12}
)
-func initClockSequence() {
- buf := make([]byte, 2)
- safeRandom(buf)
- clockSequence = binary.BigEndian.Uint16(buf)
-}
-
-func initHardwareAddr() {
- interfaces, err := net.Interfaces()
- if err == nil {
- for _, iface := range interfaces {
- if len(iface.HardwareAddr) >= 6 {
- copy(hardwareAddr[:], iface.HardwareAddr)
- return
- }
- }
- }
-
- // Initialize hardwareAddr randomly in case
- // of real network interfaces absence
- safeRandom(hardwareAddr[:])
-
- // Set multicast bit as recommended in RFC 4122
- hardwareAddr[0] |= 0x01
-}
-
-func initStorage() {
- initClockSequence()
- initHardwareAddr()
-}
-
-func safeRandom(dest []byte) {
- if _, err := rand.Read(dest); err != nil {
- panic(err)
- }
-}
-
-// Returns difference in 100-nanosecond intervals between
-// UUID epoch (October 15, 1582) and current time.
-// This is default epoch calculation function.
-func unixTimeFunc() uint64 {
- return epochStart + uint64(time.Now().UnixNano()/100)
-}
-
-// UUID representation compliant with specification
-// described in RFC 4122.
-type UUID [16]byte
-
-// NullUUID can be used with the standard sql package to represent a
-// UUID value that can be NULL in the database
-type NullUUID struct {
- UUID UUID
- Valid bool
-}
-
-// The nil UUID is special form of UUID that is specified to have all
+// Nil is special form of UUID that is specified to have all
// 128 bits set to zero.
var Nil = UUID{}
// Predefined namespace UUIDs.
var (
- NamespaceDNS, _ = FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
- NamespaceURL, _ = FromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
- NamespaceOID, _ = FromString("6ba7b812-9dad-11d1-80b4-00c04fd430c8")
- NamespaceX500, _ = FromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8")
+ NamespaceDNS = Must(FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8"))
+ NamespaceURL = Must(FromString("6ba7b811-9dad-11d1-80b4-00c04fd430c8"))
+ NamespaceOID = Must(FromString("6ba7b812-9dad-11d1-80b4-00c04fd430c8"))
+ NamespaceX500 = Must(FromString("6ba7b814-9dad-11d1-80b4-00c04fd430c8"))
)
-// And returns result of binary AND of two UUIDs.
-func And(u1 UUID, u2 UUID) UUID {
- u := UUID{}
- for i := 0; i < 16; i++ {
- u[i] = u1[i] & u2[i]
- }
- return u
-}
-
-// Or returns result of binary OR of two UUIDs.
-func Or(u1 UUID, u2 UUID) UUID {
- u := UUID{}
- for i := 0; i < 16; i++ {
- u[i] = u1[i] | u2[i]
- }
- return u
-}
-
// Equal returns true if u1 and u2 equals, otherwise returns false.
func Equal(u1 UUID, u2 UUID) bool {
return bytes.Equal(u1[:], u2[:])
}
// Version returns algorithm version used to generate UUID.
-func (u UUID) Version() uint {
- return uint(u[6] >> 4)
+func (u UUID) Version() byte {
+ return u[6] >> 4
}
// Variant returns UUID layout variant.
-func (u UUID) Variant() uint {
+func (u UUID) Variant() byte {
switch {
- case (u[8] & 0x80) == 0x00:
+ case (u[8] >> 7) == 0x00:
return VariantNCS
- case (u[8]&0xc0)|0x80 == 0x80:
+ case (u[8] >> 6) == 0x02:
return VariantRFC4122
- case (u[8]&0xe0)|0xc0 == 0xc0:
+ case (u[8] >> 5) == 0x06:
return VariantMicrosoft
+ case (u[8] >> 5) == 0x07:
+ fallthrough
+ default:
+ return VariantFuture
}
- return VariantFuture
}
// Bytes returns bytes slice representation of UUID.
@@ -198,13 +116,13 @@ func (u UUID) String() string {
buf := make([]byte, 36)
hex.Encode(buf[0:8], u[0:4])
- buf[8] = dash
+ buf[8] = '-'
hex.Encode(buf[9:13], u[4:6])
- buf[13] = dash
+ buf[13] = '-'
hex.Encode(buf[14:18], u[6:8])
- buf[18] = dash
+ buf[18] = '-'
hex.Encode(buf[19:23], u[8:10])
- buf[23] = dash
+ buf[23] = '-'
hex.Encode(buf[24:], u[10:])
return string(buf)
@@ -215,267 +133,29 @@ func (u *UUID) SetVersion(v byte) {
u[6] = (u[6] & 0x0f) | (v << 4)
}
-// SetVariant sets variant bits as described in RFC 4122.
-func (u *UUID) SetVariant() {
- u[8] = (u[8] & 0xbf) | 0x80
-}
-
-// MarshalText implements the encoding.TextMarshaler interface.
-// The encoding is the same as returned by String.
-func (u UUID) MarshalText() (text []byte, err error) {
- text = []byte(u.String())
- return
-}
-
-// UnmarshalText implements the encoding.TextUnmarshaler interface.
-// Following formats are supported:
-// "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
-// "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
-// "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
-func (u *UUID) UnmarshalText(text []byte) (err error) {
- if len(text) < 32 {
- err = fmt.Errorf("uuid: UUID string too short: %s", text)
- return
- }
-
- t := text[:]
- braced := false
-
- if bytes.Equal(t[:9], urnPrefix) {
- t = t[9:]
- } else if t[0] == '{' {
- braced = true
- t = t[1:]
+// SetVariant sets variant bits.
+func (u *UUID) SetVariant(v byte) {
+ switch v {
+ case VariantNCS:
+ u[8] = (u[8]&(0xff>>1) | (0x00 << 7))
+ case VariantRFC4122:
+ u[8] = (u[8]&(0xff>>2) | (0x02 << 6))
+ case VariantMicrosoft:
+ u[8] = (u[8]&(0xff>>3) | (0x06 << 5))
+ case VariantFuture:
+ fallthrough
+ default:
+ u[8] = (u[8]&(0xff>>3) | (0x07 << 5))
}
-
- b := u[:]
-
- for i, byteGroup := range byteGroups {
- if i > 0 {
- if t[0] != '-' {
- err = fmt.Errorf("uuid: invalid string format")
- return
- }
- t = t[1:]
- }
-
- if len(t) < byteGroup {
- err = fmt.Errorf("uuid: UUID string too short: %s", text)
- return
- }
-
- if i == 4 && len(t) > byteGroup &&
- ((braced && t[byteGroup] != '}') || len(t[byteGroup:]) > 1 || !braced) {
- err = fmt.Errorf("uuid: UUID string too long: %s", text)
- return
- }
-
- _, err = hex.Decode(b[:byteGroup/2], t[:byteGroup])
- if err != nil {
- return
- }
-
- t = t[byteGroup:]
- b = b[byteGroup/2:]
- }
-
- return
}
-// MarshalBinary implements the encoding.BinaryMarshaler interface.
-func (u UUID) MarshalBinary() (data []byte, err error) {
- data = u.Bytes()
- return
-}
-
-// UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
-// It will return error if the slice isn't 16 bytes long.
-func (u *UUID) UnmarshalBinary(data []byte) (err error) {
- if len(data) != 16 {
- err = fmt.Errorf("uuid: UUID must be exactly 16 bytes long, got %d bytes", len(data))
- return
- }
- copy(u[:], data)
-
- return
-}
-
-// Value implements the driver.Valuer interface.
-func (u UUID) Value() (driver.Value, error) {
- return u.String(), nil
-}
-
-// Scan implements the sql.Scanner interface.
-// A 16-byte slice is handled by UnmarshalBinary, while
-// a longer byte slice or a string is handled by UnmarshalText.
-func (u *UUID) Scan(src interface{}) error {
- switch src := src.(type) {
- case []byte:
- if len(src) == 16 {
- return u.UnmarshalBinary(src)
- }
- return u.UnmarshalText(src)
-
- case string:
- return u.UnmarshalText([]byte(src))
- }
-
- return fmt.Errorf("uuid: cannot convert %T to UUID", src)
-}
-
-// Value implements the driver.Valuer interface.
-func (u NullUUID) Value() (driver.Value, error) {
- if !u.Valid {
- return nil, nil
- }
- // Delegate to UUID Value function
- return u.UUID.Value()
-}
-
-// Scan implements the sql.Scanner interface.
-func (u *NullUUID) Scan(src interface{}) error {
- if src == nil {
- u.UUID, u.Valid = Nil, false
- return nil
- }
-
- // Delegate to UUID Scan function
- u.Valid = true
- return u.UUID.Scan(src)
-}
-
-// FromBytes returns UUID converted from raw byte slice input.
-// It will return error if the slice isn't 16 bytes long.
-func FromBytes(input []byte) (u UUID, err error) {
- err = u.UnmarshalBinary(input)
- return
-}
-
-// FromBytesOrNil returns UUID converted from raw byte slice input.
-// Same behavior as FromBytes, but returns a Nil UUID on error.
-func FromBytesOrNil(input []byte) UUID {
- uuid, err := FromBytes(input)
+// 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
+// initializations such as
+// var packageUUID = uuid.Must(uuid.FromString("123e4567-e89b-12d3-a456-426655440000"));
+func Must(u UUID, err error) UUID {
if err != nil {
- return Nil
- }
- return uuid
-}
-
-// FromString returns UUID parsed from string input.
-// Input is expected in a form accepted by UnmarshalText.
-func FromString(input string) (u UUID, err error) {
- err = u.UnmarshalText([]byte(input))
- return
-}
-
-// FromStringOrNil returns UUID parsed from string input.
-// Same behavior as FromString, but returns a Nil UUID on error.
-func FromStringOrNil(input string) UUID {
- uuid, err := FromString(input)
- if err != nil {
- return Nil
- }
- return uuid
-}
-
-// Returns UUID v1/v2 storage state.
-// Returns epoch timestamp, clock sequence, and hardware address.
-func getStorage() (uint64, uint16, []byte) {
- storageOnce.Do(initStorage)
-
- storageMutex.Lock()
- defer storageMutex.Unlock()
-
- timeNow := epochFunc()
- // Clock changed backwards since last UUID generation.
- // Should increase clock sequence.
- if timeNow <= lastTime {
- clockSequence++
- }
- lastTime = timeNow
-
- return timeNow, clockSequence, hardwareAddr[:]
-}
-
-// NewV1 returns UUID based on current timestamp and MAC address.
-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
-}
-
-// NewV2 returns DCE Security UUID based on POSIX UID/GID.
-func NewV2(domain byte) UUID {
- u := UUID{}
-
- timeNow, clockSeq, hardwareAddr := getStorage()
-
- switch domain {
- case DomainPerson:
- binary.BigEndian.PutUint32(u[0:], posixUID)
- case DomainGroup:
- binary.BigEndian.PutUint32(u[0:], posixGID)
+ panic(err)
}
-
- binary.BigEndian.PutUint16(u[4:], uint16(timeNow>>32))
- binary.BigEndian.PutUint16(u[6:], uint16(timeNow>>48))
- binary.BigEndian.PutUint16(u[8:], clockSeq)
- u[9] = domain
-
- copy(u[10:], hardwareAddr)
-
- u.SetVersion(2)
- u.SetVariant()
-
- return u
-}
-
-// NewV3 returns UUID based on MD5 hash of namespace UUID and name.
-func NewV3(ns UUID, name string) UUID {
- u := newFromHash(md5.New(), ns, name)
- u.SetVersion(3)
- u.SetVariant()
-
- return u
-}
-
-// NewV4 returns random generated UUID.
-func NewV4() UUID {
- u := UUID{}
- safeRandom(u[:])
- u.SetVersion(4)
- u.SetVariant()
-
- return u
-}
-
-// NewV5 returns UUID based on SHA-1 hash of namespace UUID and name.
-func NewV5(ns UUID, name string) UUID {
- u := newFromHash(sha1.New(), ns, name)
- u.SetVersion(5)
- u.SetVariant()
-
- return u
-}
-
-// Returns UUID based on hashing of namespace UUID and name.
-func newFromHash(h hash.Hash, ns UUID, name string) UUID {
- u := UUID{}
- h.Write(ns[:])
- h.Write([]byte(name))
- copy(u[:], h.Sum(nil))
-
return u
}
diff --git a/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid_test.go b/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid_test.go
index 5650480..fa40280 100644
--- a/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid_test.go
+++ b/cmd/ponzu/vendor/github.com/satori/go.uuid/uuid_test.go
@@ -1,4 +1,4 @@
-// Copyright (C) 2013, 2015 by Maxim Bublis <b@codemonkey.ru>
+// Copyright (C) 2013-2018 by Maxim Bublis <b@codemonkey.ru>
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -23,611 +23,78 @@ package uuid
import (
"bytes"
+ "fmt"
"testing"
+
+ . "gopkg.in/check.v1"
)
-func TestBytes(t *testing.T) {
- u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+// Hook up gocheck into the "go test" runner.
+func TestUUID(t *testing.T) { TestingT(t) }
- bytes1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
+type testSuite struct{}
- if !bytes.Equal(u.Bytes(), bytes1) {
- t.Errorf("Incorrect bytes representation for UUID: %s", u)
- }
-}
+var _ = Suite(&testSuite{})
-func TestString(t *testing.T) {
- if NamespaceDNS.String() != "6ba7b810-9dad-11d1-80b4-00c04fd430c8" {
- t.Errorf("Incorrect string representation for UUID: %s", NamespaceDNS.String())
- }
-}
+func (s *testSuite) TestBytes(c *C) {
+ u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
-func TestEqual(t *testing.T) {
- if !Equal(NamespaceDNS, NamespaceDNS) {
- t.Errorf("Incorrect comparison of %s and %s", NamespaceDNS, NamespaceDNS)
- }
+ bytes1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
- if Equal(NamespaceDNS, NamespaceURL) {
- t.Errorf("Incorrect comparison of %s and %s", NamespaceDNS, NamespaceURL)
- }
+ c.Assert(bytes.Equal(u.Bytes(), bytes1), Equals, true)
}
-func TestOr(t *testing.T) {
- u1 := UUID{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff}
- u2 := UUID{0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00}
-
- u := UUID{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
-
- if !Equal(u, Or(u1, u2)) {
- t.Errorf("Incorrect bitwise OR result %s", Or(u1, u2))
- }
+func (s *testSuite) TestString(c *C) {
+ c.Assert(NamespaceDNS.String(), Equals, "6ba7b810-9dad-11d1-80b4-00c04fd430c8")
}
-func TestAnd(t *testing.T) {
- u1 := UUID{0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff}
- u2 := UUID{0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00}
-
- u := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-
- if !Equal(u, And(u1, u2)) {
- t.Errorf("Incorrect bitwise AND result %s", And(u1, u2))
- }
+func (s *testSuite) TestEqual(c *C) {
+ c.Assert(Equal(NamespaceDNS, NamespaceDNS), Equals, true)
+ c.Assert(Equal(NamespaceDNS, NamespaceURL), Equals, false)
}
-func TestVersion(t *testing.T) {
+func (s *testSuite) TestVersion(c *C) {
u := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-
- if u.Version() != 1 {
- t.Errorf("Incorrect version for UUID: %d", u.Version())
- }
+ c.Assert(u.Version(), Equals, V1)
}
-func TestSetVersion(t *testing.T) {
+func (s *testSuite) TestSetVersion(c *C) {
u := UUID{}
u.SetVersion(4)
-
- if u.Version() != 4 {
- t.Errorf("Incorrect version for UUID after u.setVersion(4): %d", u.Version())
- }
+ c.Assert(u.Version(), Equals, V4)
}
-func TestVariant(t *testing.T) {
+func (s *testSuite) TestVariant(c *C) {
u1 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-
- if u1.Variant() != VariantNCS {
- t.Errorf("Incorrect variant for UUID variant %d: %d", VariantNCS, u1.Variant())
- }
+ c.Assert(u1.Variant(), Equals, VariantNCS)
u2 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-
- if u2.Variant() != VariantRFC4122 {
- t.Errorf("Incorrect variant for UUID variant %d: %d", VariantRFC4122, u2.Variant())
- }
+ c.Assert(u2.Variant(), Equals, VariantRFC4122)
u3 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-
- if u3.Variant() != VariantMicrosoft {
- t.Errorf("Incorrect variant for UUID variant %d: %d", VariantMicrosoft, u3.Variant())
- }
+ c.Assert(u3.Variant(), Equals, VariantMicrosoft)
u4 := UUID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-
- if u4.Variant() != VariantFuture {
- t.Errorf("Incorrect variant for UUID variant %d: %d", VariantFuture, u4.Variant())
- }
-}
-
-func TestSetVariant(t *testing.T) {
- u := new(UUID)
- u.SetVariant()
-
- if u.Variant() != VariantRFC4122 {
- t.Errorf("Incorrect variant for UUID after u.setVariant(): %d", u.Variant())
- }
-}
-
-func TestFromBytes(t *testing.T) {
- u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
- b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
-
- u1, err := FromBytes(b1)
- if err != nil {
- t.Errorf("Error parsing UUID from bytes: %s", err)
- }
-
- if !Equal(u, u1) {
- t.Errorf("UUIDs should be equal: %s and %s", u, u1)
- }
-
- b2 := []byte{}
-
- _, err = FromBytes(b2)
- if err == nil {
- t.Errorf("Should return error parsing from empty byte slice, got %s", err)
- }
-}
-
-func TestMarshalBinary(t *testing.T) {
- u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
- b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
-
- b2, err := u.MarshalBinary()
- if err != nil {
- t.Errorf("Error marshaling UUID: %s", err)
- }
-
- if !bytes.Equal(b1, b2) {
- t.Errorf("Marshaled UUID should be %s, got %s", b1, b2)
- }
+ c.Assert(u4.Variant(), Equals, VariantFuture)
}
-func TestUnmarshalBinary(t *testing.T) {
- u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
- b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
-
- u1 := UUID{}
- err := u1.UnmarshalBinary(b1)
- if err != nil {
- t.Errorf("Error unmarshaling UUID: %s", err)
- }
-
- if !Equal(u, u1) {
- t.Errorf("UUIDs should be equal: %s and %s", u, u1)
- }
-
- b2 := []byte{}
- u2 := UUID{}
-
- err = u2.UnmarshalBinary(b2)
- if err == nil {
- t.Errorf("Should return error unmarshalling from empty byte slice, got %s", err)
- }
-}
-
-func TestFromString(t *testing.T) {
- u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
-
- s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
- s2 := "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}"
- s3 := "urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8"
-
- _, err := FromString("")
- if err == nil {
- t.Errorf("Should return error trying to parse empty string, got %s", err)
- }
-
- u1, err := FromString(s1)
- if err != nil {
- t.Errorf("Error parsing UUID from string: %s", err)
- }
-
- if !Equal(u, u1) {
- t.Errorf("UUIDs should be equal: %s and %s", u, u1)
- }
-
- u2, err := FromString(s2)
- if err != nil {
- t.Errorf("Error parsing UUID from string: %s", err)
- }
-
- if !Equal(u, u2) {
- t.Errorf("UUIDs should be equal: %s and %s", u, u2)
- }
-
- u3, err := FromString(s3)
- if err != nil {
- t.Errorf("Error parsing UUID from string: %s", err)
- }
-
- if !Equal(u, u3) {
- t.Errorf("UUIDs should be equal: %s and %s", u, u3)
- }
-}
-
-func TestFromStringShort(t *testing.T) {
- // Invalid 35-character UUID string
- s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c"
-
- for i := len(s1); i >= 0; i-- {
- _, err := FromString(s1[:i])
- if err == nil {
- t.Errorf("Should return error trying to parse too short string, got %s", err)
- }
- }
-}
-
-func TestFromStringLong(t *testing.T) {
- // Invalid 37+ character UUID string
- s := []string{
- "6ba7b810-9dad-11d1-80b4-00c04fd430c8=",
- "6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
- "{6ba7b810-9dad-11d1-80b4-00c04fd430c8}f",
- "6ba7b810-9dad-11d1-80b4-00c04fd430c800c04fd430c8",
- }
-
- for _, str := range s {
- _, err := FromString(str)
- if err == nil {
- t.Errorf("Should return error trying to parse too long string, passed %s", str)
- }
- }
-}
-
-func TestFromStringInvalid(t *testing.T) {
- // Invalid UUID string formats
- s := []string{
- "6ba7b8109dad11d180b400c04fd430c8",
- "6ba7b8109dad11d180b400c04fd430c86ba7b8109dad11d180b400c04fd430c8",
- "urn:uuid:{6ba7b810-9dad-11d1-80b4-00c04fd430c8}",
- "6ba7b8109-dad-11d1-80b4-00c04fd430c8",
- "6ba7b810-9dad1-1d1-80b4-00c04fd430c8",
- "6ba7b810-9dad-11d18-0b4-00c04fd430c8",
- "6ba7b810-9dad-11d1-80b40-0c04fd430c8",
- "6ba7b810+9dad+11d1+80b4+00c04fd430c8",
- "6ba7b810-9dad11d180b400c04fd430c8",
- "6ba7b8109dad-11d180b400c04fd430c8",
- "6ba7b8109dad11d1-80b400c04fd430c8",
- "6ba7b8109dad11d180b4-00c04fd430c8",
- }
-
- for _, str := range s {
- _, err := FromString(str)
- if err == nil {
- t.Errorf("Should return error trying to parse invalid string, passed %s", str)
- }
- }
-}
-
-func TestFromStringOrNil(t *testing.T) {
- u := FromStringOrNil("")
- if u != Nil {
- t.Errorf("Should return Nil UUID on parse failure, got %s", u)
- }
-}
-
-func TestFromBytesOrNil(t *testing.T) {
- b := []byte{}
- u := FromBytesOrNil(b)
- if u != Nil {
- t.Errorf("Should return Nil UUID on parse failure, got %s", u)
- }
-}
-
-func TestMarshalText(t *testing.T) {
- u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
- b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
-
- b2, err := u.MarshalText()
- if err != nil {
- t.Errorf("Error marshaling UUID: %s", err)
- }
-
- if !bytes.Equal(b1, b2) {
- t.Errorf("Marshaled UUID should be %s, got %s", b1, b2)
- }
-}
-
-func TestUnmarshalText(t *testing.T) {
- u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
- b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
-
- u1 := UUID{}
- err := u1.UnmarshalText(b1)
- if err != nil {
- t.Errorf("Error unmarshaling UUID: %s", err)
- }
-
- if !Equal(u, u1) {
- t.Errorf("UUIDs should be equal: %s and %s", u, u1)
- }
-
- b2 := []byte("")
- u2 := UUID{}
-
- err = u2.UnmarshalText(b2)
- if err == nil {
- t.Errorf("Should return error trying to unmarshal from empty string")
- }
-}
-
-func TestValue(t *testing.T) {
- u, err := FromString("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
- if err != nil {
- t.Errorf("Error parsing UUID from string: %s", err)
- }
-
- val, err := u.Value()
- if err != nil {
- t.Errorf("Error getting UUID value: %s", err)
- }
-
- if val != u.String() {
- t.Errorf("Wrong value returned, should be equal: %s and %s", val, u)
- }
-}
-
-func TestValueNil(t *testing.T) {
+func (s *testSuite) TestSetVariant(c *C) {
u := UUID{}
-
- val, err := u.Value()
- if err != nil {
- t.Errorf("Error getting UUID value: %s", err)
- }
-
- if val != Nil.String() {
- t.Errorf("Wrong value returned, should be equal to UUID.Nil: %s", val)
- }
-}
-
-func TestNullUUIDValueNil(t *testing.T) {
- u := NullUUID{}
-
- val, err := u.Value()
- if err != nil {
- t.Errorf("Error getting UUID value: %s", err)
- }
-
- if val != nil {
- t.Errorf("Wrong value returned, should be nil: %s", val)
- }
-}
-
-func TestScanBinary(t *testing.T) {
- u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
- b1 := []byte{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
-
- u1 := UUID{}
- err := u1.Scan(b1)
- if err != nil {
- t.Errorf("Error unmarshaling UUID: %s", err)
- }
-
- if !Equal(u, u1) {
- t.Errorf("UUIDs should be equal: %s and %s", u, u1)
- }
-
- b2 := []byte{}
- u2 := UUID{}
-
- err = u2.Scan(b2)
- if err == nil {
- t.Errorf("Should return error unmarshalling from empty byte slice, got %s", err)
- }
-}
-
-func TestScanString(t *testing.T) {
- u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
- s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
-
- u1 := UUID{}
- err := u1.Scan(s1)
- if err != nil {
- t.Errorf("Error unmarshaling UUID: %s", err)
- }
-
- if !Equal(u, u1) {
- t.Errorf("UUIDs should be equal: %s and %s", u, u1)
- }
-
- s2 := ""
- u2 := UUID{}
-
- err = u2.Scan(s2)
- if err == nil {
- t.Errorf("Should return error trying to unmarshal from empty string")
- }
-}
-
-func TestScanText(t *testing.T) {
- u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
- b1 := []byte("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
-
- u1 := UUID{}
- err := u1.Scan(b1)
- if err != nil {
- t.Errorf("Error unmarshaling UUID: %s", err)
- }
-
- if !Equal(u, u1) {
- t.Errorf("UUIDs should be equal: %s and %s", u, u1)
- }
-
- b2 := []byte("")
- u2 := UUID{}
-
- err = u2.Scan(b2)
- if err == nil {
- t.Errorf("Should return error trying to unmarshal from empty string")
- }
-}
-
-func TestScanUnsupported(t *testing.T) {
- u := UUID{}
-
- err := u.Scan(true)
- if err == nil {
- t.Errorf("Should return error trying to unmarshal from bool")
- }
-}
-
-func TestScanNil(t *testing.T) {
- u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
-
- err := u.Scan(nil)
- if err == nil {
- t.Errorf("Error UUID shouldn't allow unmarshalling from nil")
- }
-}
-
-func TestNullUUIDScanValid(t *testing.T) {
- u := UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}
- s1 := "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
-
- u1 := NullUUID{}
- err := u1.Scan(s1)
- if err != nil {
- t.Errorf("Error unmarshaling NullUUID: %s", err)
- }
-
- if !u1.Valid {
- t.Errorf("NullUUID should be valid")
- }
-
- if !Equal(u, u1.UUID) {
- t.Errorf("UUIDs should be equal: %s and %s", u, u1.UUID)
- }
-}
-
-func TestNullUUIDScanNil(t *testing.T) {
- u := NullUUID{UUID{0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}, true}
-
- err := u.Scan(nil)
- if err != nil {
- t.Errorf("Error unmarshaling NullUUID: %s", err)
- }
-
- if u.Valid {
- t.Errorf("NullUUID should not be valid")
- }
-
- if !Equal(u.UUID, Nil) {
- t.Errorf("NullUUID value should be equal to Nil: %v", u)
- }
-}
-
-func TestNewV1(t *testing.T) {
- u := NewV1()
-
- if u.Version() != 1 {
- t.Errorf("UUIDv1 generated with incorrect version: %d", u.Version())
- }
-
- if u.Variant() != VariantRFC4122 {
- t.Errorf("UUIDv1 generated with incorrect variant: %d", u.Variant())
- }
-
- u1 := NewV1()
- u2 := NewV1()
-
- if Equal(u1, u2) {
- t.Errorf("UUIDv1 generated two equal UUIDs: %s and %s", u1, u2)
- }
-
- oldFunc := epochFunc
- epochFunc = func() uint64 { return 0 }
-
- u3 := NewV1()
- u4 := NewV1()
-
- if Equal(u3, u4) {
- t.Errorf("UUIDv1 generated two equal UUIDs: %s and %s", u3, u4)
- }
-
- epochFunc = oldFunc
-}
-
-func TestNewV2(t *testing.T) {
- u1 := NewV2(DomainPerson)
-
- if u1.Version() != 2 {
- t.Errorf("UUIDv2 generated with incorrect version: %d", u1.Version())
- }
-
- if u1.Variant() != VariantRFC4122 {
- t.Errorf("UUIDv2 generated with incorrect variant: %d", u1.Variant())
- }
-
- u2 := NewV2(DomainGroup)
-
- if u2.Version() != 2 {
- t.Errorf("UUIDv2 generated with incorrect version: %d", u2.Version())
- }
-
- if u2.Variant() != VariantRFC4122 {
- t.Errorf("UUIDv2 generated with incorrect variant: %d", u2.Variant())
- }
-}
-
-func TestNewV3(t *testing.T) {
- u := NewV3(NamespaceDNS, "www.example.com")
-
- if u.Version() != 3 {
- t.Errorf("UUIDv3 generated with incorrect version: %d", u.Version())
- }
-
- if u.Variant() != VariantRFC4122 {
- t.Errorf("UUIDv3 generated with incorrect variant: %d", u.Variant())
- }
-
- if u.String() != "5df41881-3aed-3515-88a7-2f4a814cf09e" {
- t.Errorf("UUIDv3 generated incorrectly: %s", u.String())
- }
-
- u = NewV3(NamespaceDNS, "python.org")
-
- if u.String() != "6fa459ea-ee8a-3ca4-894e-db77e160355e" {
- t.Errorf("UUIDv3 generated incorrectly: %s", u.String())
- }
-
- u1 := NewV3(NamespaceDNS, "golang.org")
- u2 := NewV3(NamespaceDNS, "golang.org")
- if !Equal(u1, u2) {
- t.Errorf("UUIDv3 generated different UUIDs for same namespace and name: %s and %s", u1, u2)
- }
-
- u3 := NewV3(NamespaceDNS, "example.com")
- if Equal(u1, u3) {
- t.Errorf("UUIDv3 generated same UUIDs for different names in same namespace: %s and %s", u1, u2)
- }
-
- u4 := NewV3(NamespaceURL, "golang.org")
- if Equal(u1, u4) {
- t.Errorf("UUIDv3 generated same UUIDs for sane names in different namespaces: %s and %s", u1, u4)
- }
-}
-
-func TestNewV4(t *testing.T) {
- u := NewV4()
-
- if u.Version() != 4 {
- t.Errorf("UUIDv4 generated with incorrect version: %d", u.Version())
- }
-
- if u.Variant() != VariantRFC4122 {
- t.Errorf("UUIDv4 generated with incorrect variant: %d", u.Variant())
- }
-}
-
-func TestNewV5(t *testing.T) {
- u := NewV5(NamespaceDNS, "www.example.com")
-
- if u.Version() != 5 {
- t.Errorf("UUIDv5 generated with incorrect version: %d", u.Version())
- }
-
- if u.Variant() != VariantRFC4122 {
- t.Errorf("UUIDv5 generated with incorrect variant: %d", u.Variant())
- }
-
- u = NewV5(NamespaceDNS, "python.org")
-
- if u.String() != "886313e1-3b8a-5372-9b90-0c9aee199e5d" {
- t.Errorf("UUIDv5 generated incorrectly: %s", u.String())
- }
-
- u1 := NewV5(NamespaceDNS, "golang.org")
- u2 := NewV5(NamespaceDNS, "golang.org")
- if !Equal(u1, u2) {
- t.Errorf("UUIDv5 generated different UUIDs for same namespace and name: %s and %s", u1, u2)
- }
-
- u3 := NewV5(NamespaceDNS, "example.com")
- if Equal(u1, u3) {
- t.Errorf("UUIDv5 generated same UUIDs for different names in same namespace: %s and %s", u1, u2)
- }
-
- u4 := NewV5(NamespaceURL, "golang.org")
- if Equal(u1, u4) {
- t.Errorf("UUIDv3 generated same UUIDs for sane names in different namespaces: %s and %s", u1, u4)
- }
+ u.SetVariant(VariantNCS)
+ c.Assert(u.Variant(), Equals, VariantNCS)
+ u.SetVariant(VariantRFC4122)
+ c.Assert(u.Variant(), Equals, VariantRFC4122)
+ u.SetVariant(VariantMicrosoft)
+ c.Assert(u.Variant(), Equals, VariantMicrosoft)
+ u.SetVariant(VariantFuture)
+ c.Assert(u.Variant(), Equals, VariantFuture)
+}
+
+func (s *testSuite) TestMust(c *C) {
+ defer func() {
+ c.Assert(recover(), NotNil)
+ }()
+ Must(func() (UUID, error) {
+ return Nil, fmt.Errorf("uuid: expected error")
+ }())
}
diff --git a/system/db/content.go b/system/db/content.go
index e73d803..b96852e 100644
--- a/system/db/content.go
+++ b/system/db/content.go
@@ -203,7 +203,11 @@ func insert(ns string, data url.Values) (int, error) {
data.Set("id", cid)
// add UUID to data for use in embedded Item
- uid := uuid.NewV4()
+ uid, err := uuid.NewV4()
+ if err != nil {
+ return err
+ }
+
data.Set("uuid", uid.String())
// if type has a specifier, add it to data for downstream processing
diff --git a/system/db/upload.go b/system/db/upload.go
index beeee2d..b7171dd 100644
--- a/system/db/upload.go
+++ b/system/db/upload.go
@@ -28,8 +28,13 @@ func SetUpload(target string, data url.Values) (int, error) {
if data.Get("uuid") == "" ||
data.Get("uuid") == (uuid.UUID{}).String() {
+
// set new UUID for upload
- data.Set("uuid", uuid.NewV4().String())
+ uid, err := uuid.NewV4()
+ if err != nil {
+ return 0, err
+ }
+ data.Set("uuid", uid.String())
}
if data.Get("slug") == "" {