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
This commit is contained in:
Shulhan 2018-11-21 17:13:03 +07:00
parent 172ffee8c3
commit 415fb3a730
5 changed files with 13 additions and 13 deletions

View File

@ -18,6 +18,7 @@ import (
"sync" "sync"
"time" "time"
"github.com/google/uuid"
"github.com/micro/go-log" "github.com/micro/go-log"
"github.com/micro/go-micro/broker/codec/json" "github.com/micro/go-micro/broker/codec/json"
merr "github.com/micro/go-micro/errors" merr "github.com/micro/go-micro/errors"
@ -26,7 +27,6 @@ import (
maddr "github.com/micro/util/go/lib/addr" maddr "github.com/micro/util/go/lib/addr"
mnet "github.com/micro/util/go/lib/net" mnet "github.com/micro/util/go/lib/net"
mls "github.com/micro/util/go/lib/tls" mls "github.com/micro/util/go/lib/tls"
"github.com/pborman/uuid"
) )
// HTTP Broker is a point to point async broker // HTTP Broker is a point to point async broker
@ -116,7 +116,7 @@ func newHttpBroker(opts ...Option) Broker {
} }
h := &httpBroker{ h := &httpBroker{
id: "broker-" + uuid.NewUUID().String(), id: "broker-" + uuid.New().String(),
address: addr, address: addr,
opts: options, opts: options,
r: reg, r: reg,
@ -413,7 +413,7 @@ func (h *httpBroker) Init(opts ...Option) error {
} }
if len(h.id) == 0 { if len(h.id) == 0 {
h.id = "broker-" + uuid.NewUUID().String() h.id = "broker-" + uuid.New().String()
} }
// get registry // get registry
@ -520,7 +520,7 @@ func (h *httpBroker) Subscribe(topic string, handler Handler, opts ...SubscribeO
} }
// create unique id // create unique id
id := h.id + "." + uuid.NewUUID().String() id := h.id + "." + uuid.New().String()
var secure bool var secure bool

View File

@ -5,15 +5,15 @@ import (
"testing" "testing"
"time" "time"
"github.com/google/uuid"
"github.com/micro/go-micro/registry/mock" "github.com/micro/go-micro/registry/mock"
"github.com/pborman/uuid"
) )
func sub(be *testing.B, c int) { func sub(be *testing.B, c int) {
be.StopTimer() be.StopTimer()
m := mock.NewRegistry() m := mock.NewRegistry()
b := NewBroker(Registry(m)) b := NewBroker(Registry(m))
topic := uuid.NewUUID().String() topic := uuid.New().String()
if err := b.Init(); err != nil { if err := b.Init(); err != nil {
be.Fatalf("Unexpected init error: %v", err) be.Fatalf("Unexpected init error: %v", err)
@ -72,7 +72,7 @@ func pub(be *testing.B, c int) {
be.StopTimer() be.StopTimer()
m := mock.NewRegistry() m := mock.NewRegistry()
b := NewBroker(Registry(m)) b := NewBroker(Registry(m))
topic := uuid.NewUUID().String() topic := uuid.New().String()
if err := b.Init(); err != nil { if err := b.Init(); err != nil {
be.Fatalf("Unexpected init error: %v", err) be.Fatalf("Unexpected init error: %v", err)

View File

@ -4,8 +4,8 @@ import (
"errors" "errors"
"sync" "sync"
"github.com/google/uuid"
"github.com/micro/go-micro/broker" "github.com/micro/go-micro/broker"
"github.com/pborman/uuid"
) )
type mockBroker struct { type mockBroker struct {
@ -112,7 +112,7 @@ func (m *mockBroker) Subscribe(topic string, handler broker.Handler, opts ...bro
sub := &mockSubscriber{ sub := &mockSubscriber{
exit: make(chan bool, 1), exit: make(chan bool, 1),
id: uuid.NewUUID().String(), id: uuid.New().String(),
topic: topic, topic: topic,
handler: handler, handler: handler,
opts: options, opts: options,

View File

@ -4,8 +4,8 @@ import (
"errors" "errors"
"sync" "sync"
"github.com/google/uuid"
"github.com/micro/go-micro/server" "github.com/micro/go-micro/server"
"github.com/pborman/uuid"
) )
type MockServer struct { type MockServer struct {
@ -69,7 +69,7 @@ func (m *MockServer) NewHandler(h interface{}, opts ...server.HandlerOption) ser
} }
return &MockHandler{ return &MockHandler{
Id: uuid.NewUUID().String(), Id: uuid.New().String(),
Hdlr: h, Hdlr: h,
Opts: options, Opts: options,
} }

View File

@ -7,8 +7,8 @@ import (
"os/signal" "os/signal"
"syscall" "syscall"
"github.com/google/uuid"
"github.com/micro/go-log" "github.com/micro/go-log"
"github.com/pborman/uuid"
) )
type Server interface { type Server interface {
@ -63,7 +63,7 @@ var (
DefaultAddress = ":0" DefaultAddress = ":0"
DefaultName = "go-server" DefaultName = "go-server"
DefaultVersion = "1.0.0" DefaultVersion = "1.0.0"
DefaultId = uuid.NewUUID().String() DefaultId = uuid.New().String()
DefaultServer Server = newRpcServer() DefaultServer Server = newRpcServer()
) )