summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/pborman
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-07-20 15:22:49 -0700
committerGitHub <noreply@github.com>2017-07-20 15:22:49 -0700
commit58839cefb50e56ae5b157b37e9814ae83ceee70b (patch)
tree5de966481678096fc9567f74f96673b34a65127c /vendor/github.com/pborman
parente2f4492eadb5d3c58606b1fdd5774b63a07c236a (diff)
downloadchat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.gz
chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.bz2
chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.zip
Upgrading server dependancies (#6984)
Diffstat (limited to 'vendor/github.com/pborman')
-rw-r--r--vendor/github.com/pborman/uuid/.travis.yml1
-rw-r--r--vendor/github.com/pborman/uuid/CONTRIBUTING.md10
-rw-r--r--vendor/github.com/pborman/uuid/README.md2
-rw-r--r--[-rwxr-xr-x]vendor/github.com/pborman/uuid/dce.go0
-rw-r--r--[-rwxr-xr-x]vendor/github.com/pborman/uuid/doc.go0
-rw-r--r--vendor/github.com/pborman/uuid/json.go34
-rw-r--r--vendor/github.com/pborman/uuid/json_test.go61
-rw-r--r--vendor/github.com/pborman/uuid/marshal.go83
-rw-r--r--vendor/github.com/pborman/uuid/marshal_test.go124
-rw-r--r--[-rwxr-xr-x]vendor/github.com/pborman/uuid/node.go0
-rw-r--r--vendor/github.com/pborman/uuid/sql.go8
-rw-r--r--vendor/github.com/pborman/uuid/sql_test.go9
-rw-r--r--[-rwxr-xr-x]vendor/github.com/pborman/uuid/time.go0
-rw-r--r--vendor/github.com/pborman/uuid/uuid.go27
-rw-r--r--vendor/github.com/pborman/uuid/uuid_test.go78
15 files changed, 336 insertions, 101 deletions
diff --git a/vendor/github.com/pborman/uuid/.travis.yml b/vendor/github.com/pborman/uuid/.travis.yml
index a6a98db8a..d8156a60b 100644
--- a/vendor/github.com/pborman/uuid/.travis.yml
+++ b/vendor/github.com/pborman/uuid/.travis.yml
@@ -3,7 +3,6 @@ language: go
go:
- 1.4.3
- 1.5.3
- - release
- tip
script:
diff --git a/vendor/github.com/pborman/uuid/CONTRIBUTING.md b/vendor/github.com/pborman/uuid/CONTRIBUTING.md
new file mode 100644
index 000000000..04fdf09f1
--- /dev/null
+++ b/vendor/github.com/pborman/uuid/CONTRIBUTING.md
@@ -0,0 +1,10 @@
+# How to contribute
+
+We definitely welcome patches and contribution to this project!
+
+### Legal requirements
+
+In order to protect both you and ourselves, you will need to sign the
+[Contributor License Agreement](https://cla.developers.google.com/clas).
+
+You may have already signed it for other Google projects.
diff --git a/vendor/github.com/pborman/uuid/README.md b/vendor/github.com/pborman/uuid/README.md
index f023d47ca..b0396b274 100644
--- a/vendor/github.com/pborman/uuid/README.md
+++ b/vendor/github.com/pborman/uuid/README.md
@@ -1,7 +1,7 @@
This project was automatically exported from code.google.com/p/go-uuid
# uuid ![build status](https://travis-ci.org/pborman/uuid.svg?branch=master)
-The uuid package generates and inspects UUIDs based on [RFC 412](http://tools.ietf.org/html/rfc4122) and DCE 1.1: Authentication and Security Services.
+The uuid package generates and inspects UUIDs based on [RFC 4122](http://tools.ietf.org/html/rfc4122) and DCE 1.1: Authentication and Security Services.
###### Install
`go get github.com/pborman/uuid`
diff --git a/vendor/github.com/pborman/uuid/dce.go b/vendor/github.com/pborman/uuid/dce.go
index 50a0f2d09..50a0f2d09 100755..100644
--- a/vendor/github.com/pborman/uuid/dce.go
+++ b/vendor/github.com/pborman/uuid/dce.go
diff --git a/vendor/github.com/pborman/uuid/doc.go b/vendor/github.com/pborman/uuid/doc.go
index d8bd013e6..d8bd013e6 100755..100644
--- a/vendor/github.com/pborman/uuid/doc.go
+++ b/vendor/github.com/pborman/uuid/doc.go
diff --git a/vendor/github.com/pborman/uuid/json.go b/vendor/github.com/pborman/uuid/json.go
deleted file mode 100644
index 9dda1dfba..000000000
--- a/vendor/github.com/pborman/uuid/json.go
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2014 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package uuid
-
-import "errors"
-
-func (u UUID) MarshalJSON() ([]byte, error) {
- if len(u) != 16 {
- return []byte(`""`), nil
- }
- var js [38]byte
- js[0] = '"'
- encodeHex(js[1:], u)
- js[37] = '"'
- return js[:], nil
-}
-
-func (u *UUID) UnmarshalJSON(data []byte) error {
- if string(data) == `""` {
- return nil
- }
- if data[0] != '"' {
- return errors.New("invalid UUID format")
- }
- data = data[1 : len(data)-1]
- uu := Parse(string(data))
- if uu == nil {
- return errors.New("invalid UUID format")
- }
- *u = uu
- return nil
-}
diff --git a/vendor/github.com/pborman/uuid/json_test.go b/vendor/github.com/pborman/uuid/json_test.go
deleted file mode 100644
index 2866b8dc8..000000000
--- a/vendor/github.com/pborman/uuid/json_test.go
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2014 Google Inc. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package uuid
-
-import (
- "encoding/json"
- "reflect"
- "testing"
-)
-
-var testUUID = Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479")
-
-func TestJSON(t *testing.T) {
- type S struct {
- ID1 UUID
- ID2 UUID
- }
- s1 := S{ID1: testUUID}
- data, err := json.Marshal(&s1)
- if err != nil {
- t.Fatal(err)
- }
- var s2 S
- if err := json.Unmarshal(data, &s2); err != nil {
- t.Fatal(err)
- }
- if !reflect.DeepEqual(&s1, &s2) {
- t.Errorf("got %#v, want %#v", s2, s1)
- }
-}
-
-func BenchmarkUUID_MarshalJSON(b *testing.B) {
- x := &struct {
- UUID UUID `json:"uuid"`
- }{}
- x.UUID = Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479")
- if x.UUID == nil {
- b.Fatal("invalid uuid")
- }
- for i := 0; i < b.N; i++ {
- js, err := json.Marshal(x)
- if err != nil {
- b.Fatalf("marshal json: %#v (%v)", js, err)
- }
- }
-}
-
-func BenchmarkUUID_UnmarshalJSON(b *testing.B) {
- js := []byte(`{"uuid":"f47ac10b-58cc-0372-8567-0e02b2c3d479"}`)
- var x *struct {
- UUID UUID `json:"uuid"`
- }
- for i := 0; i < b.N; i++ {
- err := json.Unmarshal(js, &x)
- if err != nil {
- b.Fatalf("marshal json: %#v (%v)", js, err)
- }
- }
-}
diff --git a/vendor/github.com/pborman/uuid/marshal.go b/vendor/github.com/pborman/uuid/marshal.go
new file mode 100644
index 000000000..6621dd54b
--- /dev/null
+++ b/vendor/github.com/pborman/uuid/marshal.go
@@ -0,0 +1,83 @@
+// Copyright 2016 Google Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package uuid
+
+import (
+ "errors"
+ "fmt"
+)
+
+// MarshalText implements encoding.TextMarshaler.
+func (u UUID) MarshalText() ([]byte, error) {
+ if len(u) != 16 {
+ return nil, nil
+ }
+ var js [36]byte
+ encodeHex(js[:], u)
+ return js[:], nil
+}
+
+// UnmarshalText implements encoding.TextUnmarshaler.
+func (u *UUID) UnmarshalText(data []byte) error {
+ if len(data) == 0 {
+ return nil
+ }
+ id := Parse(string(data))
+ if id == nil {
+ return errors.New("invalid UUID")
+ }
+ *u = id
+ return nil
+}
+
+// MarshalBinary implements encoding.BinaryMarshaler.
+func (u UUID) MarshalBinary() ([]byte, error) {
+ return u[:], nil
+}
+
+// UnmarshalBinary implements encoding.BinaryUnmarshaler.
+func (u *UUID) UnmarshalBinary(data []byte) error {
+ if len(data) == 0 {
+ return nil
+ }
+ if len(data) != 16 {
+ return fmt.Errorf("invalid UUID (got %d bytes)", len(data))
+ }
+ var id [16]byte
+ copy(id[:], data)
+ *u = id[:]
+ return nil
+}
+
+// MarshalText implements encoding.TextMarshaler.
+func (u Array) MarshalText() ([]byte, error) {
+ var js [36]byte
+ encodeHex(js[:], u[:])
+ return js[:], nil
+}
+
+// UnmarshalText implements encoding.TextUnmarshaler.
+func (u *Array) UnmarshalText(data []byte) error {
+ id := Parse(string(data))
+ if id == nil {
+ return errors.New("invalid UUID")
+ }
+ *u = id.Array()
+ return nil
+}
+
+// MarshalBinary implements encoding.BinaryMarshaler.
+func (u Array) MarshalBinary() ([]byte, error) {
+ return u[:], nil
+}
+
+// UnmarshalBinary implements encoding.BinaryUnmarshaler.
+func (u *Array) UnmarshalBinary(data []byte) error {
+ if len(data) != 16 {
+ return fmt.Errorf("invalid UUID (got %d bytes)", len(data))
+ }
+ copy(u[:], data)
+ return nil
+}
diff --git a/vendor/github.com/pborman/uuid/marshal_test.go b/vendor/github.com/pborman/uuid/marshal_test.go
new file mode 100644
index 000000000..4e85b6bab
--- /dev/null
+++ b/vendor/github.com/pborman/uuid/marshal_test.go
@@ -0,0 +1,124 @@
+// Copyright 2014 Google Inc. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package uuid
+
+import (
+ "bytes"
+ "encoding/json"
+ "reflect"
+ "testing"
+)
+
+var testUUID = Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479")
+var testArray = testUUID.Array()
+
+func TestJSON(t *testing.T) {
+ type S struct {
+ ID1 UUID
+ ID2 UUID
+ }
+ s1 := S{ID1: testUUID}
+ data, err := json.Marshal(&s1)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var s2 S
+ if err := json.Unmarshal(data, &s2); err != nil {
+ t.Fatal(err)
+ }
+ if !reflect.DeepEqual(&s1, &s2) {
+ t.Errorf("got %#v, want %#v", s2, s1)
+ }
+}
+
+func TestJSONArray(t *testing.T) {
+ type S struct {
+ ID1 Array
+ ID2 Array
+ }
+ s1 := S{ID1: testArray}
+ data, err := json.Marshal(&s1)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var s2 S
+ if err := json.Unmarshal(data, &s2); err != nil {
+ t.Fatal(err)
+ }
+ if !reflect.DeepEqual(&s1, &s2) {
+ t.Errorf("got %#v, want %#v", s2, s1)
+ }
+}
+
+func TestMarshal(t *testing.T) {
+ data, err := testUUID.MarshalBinary()
+ if err != nil {
+ t.Fatalf("MarhsalBinary returned unexpected error %v", err)
+ }
+ if !bytes.Equal(data, testUUID) {
+ t.Fatalf("MarhsalBinary returns %x, want %x", data, testUUID)
+ }
+ var u UUID
+ u.UnmarshalBinary(data)
+ if !Equal(data, u) {
+ t.Fatalf("UnmarhsalBinary returns %v, want %v", u, testUUID)
+ }
+}
+
+func TestMarshalArray(t *testing.T) {
+ data, err := testArray.MarshalBinary()
+ if err != nil {
+ t.Fatalf("MarhsalBinary returned unexpected error %v", err)
+ }
+ if !bytes.Equal(data, testUUID) {
+ t.Fatalf("MarhsalBinary returns %x, want %x", data, testUUID)
+ }
+ var a Array
+ a.UnmarshalBinary(data)
+ if a != testArray {
+ t.Fatalf("UnmarhsalBinary returns %v, want %v", a, testArray)
+ }
+}
+
+func TestMarshalTextArray(t *testing.T) {
+ data, err := testArray.MarshalText()
+ if err != nil {
+ t.Fatalf("MarhsalText returned unexpected error %v", err)
+ }
+ var a Array
+ a.UnmarshalText(data)
+ if a != testArray {
+ t.Fatalf("UnmarhsalText returns %v, want %v", a, testArray)
+ }
+}
+
+func BenchmarkUUID_MarshalJSON(b *testing.B) {
+ x := &struct {
+ UUID UUID `json:"uuid"`
+ }{}
+ x.UUID = Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479")
+ if x.UUID == nil {
+ b.Fatal("invalid uuid")
+ }
+ for i := 0; i < b.N; i++ {
+ js, err := json.Marshal(x)
+ if err != nil {
+ b.Fatalf("marshal json: %#v (%v)", js, err)
+ }
+ }
+}
+
+func BenchmarkUUID_UnmarshalJSON(b *testing.B) {
+ js := []byte(`{"uuid":"f47ac10b-58cc-0372-8567-0e02b2c3d479"}`)
+ var x *struct {
+ UUID UUID `json:"uuid"`
+ }
+ for i := 0; i < b.N; i++ {
+ err := json.Unmarshal(js, &x)
+ if err != nil {
+ b.Fatalf("marshal json: %#v (%v)", js, err)
+ }
+ }
+}
diff --git a/vendor/github.com/pborman/uuid/node.go b/vendor/github.com/pborman/uuid/node.go
index 42d60da8f..42d60da8f 100755..100644
--- a/vendor/github.com/pborman/uuid/node.go
+++ b/vendor/github.com/pborman/uuid/node.go
diff --git a/vendor/github.com/pborman/uuid/sql.go b/vendor/github.com/pborman/uuid/sql.go
index c84f900d5..d015bfd13 100644
--- a/vendor/github.com/pborman/uuid/sql.go
+++ b/vendor/github.com/pborman/uuid/sql.go
@@ -5,6 +5,7 @@
package uuid
import (
+ "database/sql/driver"
"errors"
"fmt"
)
@@ -56,3 +57,10 @@ func (uuid *UUID) Scan(src interface{}) error {
return nil
}
+
+// Value implements sql.Valuer so that UUIDs can be written to databases
+// transparently. Currently, UUIDs map to strings. Please consult
+// database-specific driver documentation for matching types.
+func (uuid UUID) Value() (driver.Value, error) {
+ return uuid.String(), nil
+}
diff --git a/vendor/github.com/pborman/uuid/sql_test.go b/vendor/github.com/pborman/uuid/sql_test.go
index 4d26392af..103095156 100644
--- a/vendor/github.com/pborman/uuid/sql_test.go
+++ b/vendor/github.com/pborman/uuid/sql_test.go
@@ -85,3 +85,12 @@ func TestScan(t *testing.T) {
t.Error("UUID was not nil after scanning empty string")
}
}
+
+func TestValue(t *testing.T) {
+ stringTest := "f47ac10b-58cc-0372-8567-0e02b2c3d479"
+ uuid := Parse(stringTest)
+ val, _ := uuid.Value()
+ if val != stringTest {
+ t.Error("Value() did not return expected string")
+ }
+}
diff --git a/vendor/github.com/pborman/uuid/time.go b/vendor/github.com/pborman/uuid/time.go
index eedf24219..eedf24219 100755..100644
--- a/vendor/github.com/pborman/uuid/time.go
+++ b/vendor/github.com/pborman/uuid/time.go
diff --git a/vendor/github.com/pborman/uuid/uuid.go b/vendor/github.com/pborman/uuid/uuid.go
index c4482cd87..7c643cf0a 100644
--- a/vendor/github.com/pborman/uuid/uuid.go
+++ b/vendor/github.com/pborman/uuid/uuid.go
@@ -13,6 +13,20 @@ import (
"strings"
)
+// Array is a pass-by-value UUID that can be used as an effecient key in a map.
+type Array [16]byte
+
+// UUID converts uuid into a slice.
+func (uuid Array) UUID() UUID {
+ return uuid[:]
+}
+
+// String returns the string representation of uuid,
+// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
+func (uuid Array) String() string {
+ return uuid.UUID().String()
+}
+
// A UUID is a 128 bit (16 byte) Universal Unique IDentifier as defined in RFC
// 4122.
type UUID []byte
@@ -76,6 +90,17 @@ func Equal(uuid1, uuid2 UUID) bool {
return bytes.Equal(uuid1, uuid2)
}
+// Array returns an array representation of uuid that can be used as a map key.
+// Array panics if uuid is not valid.
+func (uuid UUID) Array() Array {
+ if len(uuid) != 16 {
+ panic("invalid uuid")
+ }
+ var a Array
+ copy(a[:], uuid)
+ return a
+}
+
// String returns the string form of uuid, xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
// , or "" if uuid is invalid.
func (uuid UUID) String() string {
@@ -161,7 +186,7 @@ func (v Variant) String() string {
return fmt.Sprintf("BadVariant%d", int(v))
}
-// SetRand sets the random number generator to r, which implents io.Reader.
+// SetRand sets the random number generator to r, which implements io.Reader.
// If r.Read returns an error when the package requests random data then
// a panic will be issued.
//
diff --git a/vendor/github.com/pborman/uuid/uuid_test.go b/vendor/github.com/pborman/uuid/uuid_test.go
index 3835cc808..038723966 100644
--- a/vendor/github.com/pborman/uuid/uuid_test.go
+++ b/vendor/github.com/pborman/uuid/uuid_test.go
@@ -300,7 +300,7 @@ func TestNode(t *testing.T) {
t.Error("nodeid is all zeros")
}
- id := []byte{1,2,3,4,5,6,7,8}
+ id := []byte{1, 2, 3, 4, 5, 6, 7, 8}
SetNodeID(id)
ni = NodeID()
if !bytes.Equal(ni, id[:6]) {
@@ -421,13 +421,47 @@ func TestBadRand(t *testing.T) {
uuid1 := New()
uuid2 := New()
if uuid1 != uuid2 {
- t.Errorf("execpted duplicates, got %q and %q", uuid1, uuid2)
+ t.Errorf("expected duplicates, got %q and %q", uuid1, uuid2)
}
SetRand(nil)
uuid1 = New()
uuid2 = New()
if uuid1 == uuid2 {
- t.Errorf("unexecpted duplicates, got %q", uuid1)
+ t.Errorf("unexpected duplicates, got %q", uuid1)
+ }
+}
+
+func TestUUID_Array(t *testing.T) {
+ expect := Array{
+ 0xf4, 0x7a, 0xc1, 0x0b,
+ 0x58, 0xcc,
+ 0x03, 0x72,
+ 0x85, 0x67,
+ 0x0e, 0x02, 0xb2, 0xc3, 0xd4, 0x79,
+ }
+ uuid := Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479")
+ if uuid == nil {
+ t.Fatal("invalid uuid")
+ }
+ if uuid.Array() != expect {
+ t.Fatal("invalid array")
+ }
+}
+
+func TestArray_UUID(t *testing.T) {
+ array := Array{
+ 0xf4, 0x7a, 0xc1, 0x0b,
+ 0x58, 0xcc,
+ 0x03, 0x72,
+ 0x85, 0x67,
+ 0x0e, 0x02, 0xb2, 0xc3, 0xd4, 0x79,
+ }
+ expect := Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479")
+ if expect == nil {
+ t.Fatal("invalid uuid")
+ }
+ if !bytes.Equal(array.UUID(), expect) {
+ t.Fatal("invalid uuid")
}
}
@@ -469,3 +503,41 @@ func BenchmarkUUID_URN(b *testing.B) {
}
}
}
+
+func BenchmarkUUID_Array(b *testing.B) {
+ expect := Array{
+ 0xf4, 0x7a, 0xc1, 0x0b,
+ 0x58, 0xcc,
+ 0x03, 0x72,
+ 0x85, 0x67,
+ 0x0e, 0x02, 0xb2, 0xc3, 0xd4, 0x79,
+ }
+ uuid := Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479")
+ if uuid == nil {
+ b.Fatal("invalid uuid")
+ }
+ for i := 0; i < b.N; i++ {
+ if uuid.Array() != expect {
+ b.Fatal("invalid array")
+ }
+ }
+}
+
+func BenchmarkArray_UUID(b *testing.B) {
+ array := Array{
+ 0xf4, 0x7a, 0xc1, 0x0b,
+ 0x58, 0xcc,
+ 0x03, 0x72,
+ 0x85, 0x67,
+ 0x0e, 0x02, 0xb2, 0xc3, 0xd4, 0x79,
+ }
+ expect := Parse("f47ac10b-58cc-0372-8567-0e02b2c3d479")
+ if expect == nil {
+ b.Fatal("invalid uuid")
+ }
+ for i := 0; i < b.N; i++ {
+ if !bytes.Equal(array.UUID(), expect) {
+ b.Fatal("invalid uuid")
+ }
+ }
+}