From 415fb3a730349252f0f048e01989a5397c6a8e72 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Wed, 21 Nov 2018 17:13:03 +0700 Subject: [PATCH] all: replace "pborman/uuid" with "google/uuid" Internally, "pborman/uuid.NewUUID()" is calling "google/uuid.New()" that return nil when there is an error [1]. Both package use the same license. [1] https://github.com/pborman/uuid/blob/master/version1.go#L17 --- broker/http_broker.go | 8 ++++---- broker/http_broker_test.go | 6 +++--- broker/mock/mock.go | 4 ++-- server/mock/mock.go | 4 ++-- server/server.go | 4 ++-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/broker/http_broker.go b/broker/http_broker.go index c43d85be..3ff42aa2 100644 --- a/broker/http_broker.go +++ b/broker/http_broker.go @@ -18,6 +18,7 @@ import ( "sync" "time" + "github.com/google/uuid" "github.com/micro/go-log" "github.com/micro/go-micro/broker/codec/json" merr "github.com/micro/go-micro/errors" @@ -26,7 +27,6 @@ import ( maddr "github.com/micro/util/go/lib/addr" mnet "github.com/micro/util/go/lib/net" mls "github.com/micro/util/go/lib/tls" - "github.com/pborman/uuid" ) // HTTP Broker is a point to point async broker @@ -116,7 +116,7 @@ func newHttpBroker(opts ...Option) Broker { } h := &httpBroker{ - id: "broker-" + uuid.NewUUID().String(), + id: "broker-" + uuid.New().String(), address: addr, opts: options, r: reg, @@ -413,7 +413,7 @@ func (h *httpBroker) Init(opts ...Option) error { } if len(h.id) == 0 { - h.id = "broker-" + uuid.NewUUID().String() + h.id = "broker-" + uuid.New().String() } // get registry @@ -520,7 +520,7 @@ func (h *httpBroker) Subscribe(topic string, handler Handler, opts ...SubscribeO } // create unique id - id := h.id + "." + uuid.NewUUID().String() + id := h.id + "." + uuid.New().String() var secure bool diff --git a/broker/http_broker_test.go b/broker/http_broker_test.go index 9a84db29..e987835d 100644 --- a/broker/http_broker_test.go +++ b/broker/http_broker_test.go @@ -5,15 +5,15 @@ import ( "testing" "time" + "github.com/google/uuid" "github.com/micro/go-micro/registry/mock" - "github.com/pborman/uuid" ) func sub(be *testing.B, c int) { be.StopTimer() m := mock.NewRegistry() b := NewBroker(Registry(m)) - topic := uuid.NewUUID().String() + topic := uuid.New().String() if err := b.Init(); err != nil { be.Fatalf("Unexpected init error: %v", err) @@ -72,7 +72,7 @@ func pub(be *testing.B, c int) { be.StopTimer() m := mock.NewRegistry() b := NewBroker(Registry(m)) - topic := uuid.NewUUID().String() + topic := uuid.New().String() if err := b.Init(); err != nil { be.Fatalf("Unexpected init error: %v", err) diff --git a/broker/mock/mock.go b/broker/mock/mock.go index 5a9a323a..842906a2 100644 --- a/broker/mock/mock.go +++ b/broker/mock/mock.go @@ -4,8 +4,8 @@ import ( "errors" "sync" + "github.com/google/uuid" "github.com/micro/go-micro/broker" - "github.com/pborman/uuid" ) type mockBroker struct { @@ -112,7 +112,7 @@ func (m *mockBroker) Subscribe(topic string, handler broker.Handler, opts ...bro sub := &mockSubscriber{ exit: make(chan bool, 1), - id: uuid.NewUUID().String(), + id: uuid.New().String(), topic: topic, handler: handler, opts: options, diff --git a/server/mock/mock.go b/server/mock/mock.go index f853b905..ce2a4671 100644 --- a/server/mock/mock.go +++ b/server/mock/mock.go @@ -4,8 +4,8 @@ import ( "errors" "sync" + "github.com/google/uuid" "github.com/micro/go-micro/server" - "github.com/pborman/uuid" ) type MockServer struct { @@ -69,7 +69,7 @@ func (m *MockServer) NewHandler(h interface{}, opts ...server.HandlerOption) ser } return &MockHandler{ - Id: uuid.NewUUID().String(), + Id: uuid.New().String(), Hdlr: h, Opts: options, } diff --git a/server/server.go b/server/server.go index a320fe8f..6a661266 100644 --- a/server/server.go +++ b/server/server.go @@ -7,8 +7,8 @@ import ( "os/signal" "syscall" + "github.com/google/uuid" "github.com/micro/go-log" - "github.com/pborman/uuid" ) type Server interface { @@ -63,7 +63,7 @@ var ( DefaultAddress = ":0" DefaultName = "go-server" DefaultVersion = "1.0.0" - DefaultId = uuid.NewUUID().String() + DefaultId = uuid.New().String() DefaultServer Server = newRpcServer() )