From cf8fe4a477596f78341eafa0dca2f378719cbb4a Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 14 Sep 2019 19:57:32 -0500 Subject: [PATCH] uuid extension switched to gofrs from satori Do not encourage library use that has serious outstanding bug: https://github.com/satori/go.uuid/issues/73 --- ext/{satori-uuid => gofrs-uuid}/uuid.go | 2 +- ext/{satori-uuid => gofrs-uuid}/uuid_test.go | 22 ++++++++++---------- go.mod | 2 +- go.sum | 2 ++ 4 files changed, 15 insertions(+), 13 deletions(-) rename ext/{satori-uuid => gofrs-uuid}/uuid.go (99%) rename ext/{satori-uuid => gofrs-uuid}/uuid_test.go (63%) diff --git a/ext/satori-uuid/uuid.go b/ext/gofrs-uuid/uuid.go similarity index 99% rename from ext/satori-uuid/uuid.go rename to ext/gofrs-uuid/uuid.go index 9b958b5..9b95a22 100644 --- a/ext/satori-uuid/uuid.go +++ b/ext/gofrs-uuid/uuid.go @@ -5,8 +5,8 @@ import ( errors "golang.org/x/xerrors" + "github.com/gofrs/uuid" "github.com/jackc/pgtype" - uuid "github.com/satori/go.uuid" ) var errUndefined = errors.New("cannot encode status undefined") diff --git a/ext/satori-uuid/uuid_test.go b/ext/gofrs-uuid/uuid_test.go similarity index 63% rename from ext/satori-uuid/uuid_test.go rename to ext/gofrs-uuid/uuid_test.go index 247470a..124720b 100644 --- a/ext/satori-uuid/uuid_test.go +++ b/ext/gofrs-uuid/uuid_test.go @@ -5,38 +5,38 @@ import ( "testing" "github.com/jackc/pgtype" - satori "github.com/jackc/pgtype/ext/satori-uuid" + gofrs "github.com/jackc/pgtype/ext/gofrs-uuid" "github.com/jackc/pgtype/testutil" ) func TestUUIDTranscode(t *testing.T) { testutil.TestSuccessfulTranscode(t, "uuid", []interface{}{ - &satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, - &satori.UUID{Status: pgtype.Null}, + &gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, + &gofrs.UUID{Status: pgtype.Null}, }) } func TestUUIDSet(t *testing.T) { successfulTests := []struct { source interface{} - result satori.UUID + result gofrs.UUID }{ { source: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, - result: satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, + result: gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, }, { source: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, - result: satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, + result: gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, }, { source: "00010203-0405-0607-0809-0a0b0c0d0e0f", - result: satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, + result: gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present}, }, } for i, tt := range successfulTests { - var r satori.UUID + var r gofrs.UUID err := r.Set(tt.source) if err != nil { t.Errorf("%d: %v", i, err) @@ -50,7 +50,7 @@ func TestUUIDSet(t *testing.T) { func TestUUIDAssignTo(t *testing.T) { { - src := satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present} + src := gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present} var dst [16]byte expected := [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} @@ -65,7 +65,7 @@ func TestUUIDAssignTo(t *testing.T) { } { - src := satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present} + src := gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present} var dst []byte expected := []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} @@ -80,7 +80,7 @@ func TestUUIDAssignTo(t *testing.T) { } { - src := satori.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present} + src := gofrs.UUID{UUID: [16]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, Status: pgtype.Present} var dst string expected := "00010203-0405-0607-0809-0a0b0c0d0e0f" diff --git a/go.mod b/go.mod index dbe9f53..9f47a70 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module github.com/jackc/pgtype go 1.12 require ( + github.com/gofrs/uuid v3.2.0+incompatible github.com/jackc/pgio v1.0.0 github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186 github.com/lib/pq v1.2.0 - github.com/satori/go.uuid v1.2.0 github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 github.com/stretchr/testify v1.4.0 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 diff --git a/go.sum b/go.sum index f9a56ff..275e7fe 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= +github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= github.com/jackc/chunkreader/v2 v2.0.0 h1:DUwgMQuuPnS0rhMXenUtZpqZqrR/30NWY+qQvTpSvEs=