From ef87f84fd8202892f129f894700425e571529318 Mon Sep 17 00:00:00 2001 From: Vytenis Darulis Date: Sat, 5 Dec 2020 15:07:34 -0500 Subject: [PATCH] Remove odd uses of satori/go.uuid package (#2985) --- go.mod | 1 - src/dbnode/namespace/kvadmin/ns_admin.go | 4 ++-- src/m3em/node/node.go | 6 +++--- src/m3ninx/util/uuid.go | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 8fa319d98c..6dd0152e39 100644 --- a/go.mod +++ b/go.mod @@ -90,7 +90,6 @@ require ( github.com/remeh/sizedwaitgroup v1.0.0 // indirect github.com/rhysd/go-github-selfupdate v1.2.2 // indirect github.com/rveen/ogdl v0.0.0-20200522080342-eeeda1a978e7 // indirect - github.com/satori/go.uuid v1.2.0 github.com/sergi/go-diff v1.1.0 github.com/shirou/gopsutil v2.20.5+incompatible // indirect github.com/sirupsen/logrus v1.7.0 // indirect diff --git a/src/dbnode/namespace/kvadmin/ns_admin.go b/src/dbnode/namespace/kvadmin/ns_admin.go index f5ba819c4a..d1ba91c63e 100644 --- a/src/dbnode/namespace/kvadmin/ns_admin.go +++ b/src/dbnode/namespace/kvadmin/ns_admin.go @@ -24,7 +24,7 @@ import ( "errors" "fmt" - uuid "github.com/satori/go.uuid" + "github.com/pborman/uuid" "github.com/m3db/m3/src/cluster/kv" nsproto "github.com/m3db/m3/src/dbnode/generated/proto/namespace" @@ -53,7 +53,7 @@ const ( func NewAdminService(store kv.Store, key string, idGen func() string) NamespaceMetadataAdminService { if idGen == nil { idGen = func() string { - return uuid.NewV4().String() + return uuid.New() } } if len(key) == 0 { diff --git a/src/m3em/node/node.go b/src/m3em/node/node.go index 494fa08a0c..a54bf0de52 100644 --- a/src/m3em/node/node.go +++ b/src/m3em/node/node.go @@ -35,7 +35,7 @@ import ( xclock "github.com/m3db/m3/src/x/clock" xerrors "github.com/m3db/m3/src/x/errors" - uuid "github.com/satori/go.uuid" + "github.com/pborman/uuid" "go.uber.org/zap" "google.golang.org/grpc" ) @@ -78,7 +78,7 @@ func New( return nil, err } - uuid := uuid.NewV4().Bytes() + uuid := uuid.NewRandom() var ( retNode = &svcNode{ @@ -88,7 +88,7 @@ func New( status: StatusUninitialized, } listeners = newListenerGroup(retNode) - hbUUID = string(uuid[:]) + hbUUID = uuid.String() heartbeater *opHeartbeatServer routerEndpoint string ) diff --git a/src/m3ninx/util/uuid.go b/src/m3ninx/util/uuid.go index 180b427869..a32af520f0 100644 --- a/src/m3ninx/util/uuid.go +++ b/src/m3ninx/util/uuid.go @@ -24,12 +24,12 @@ import ( "encoding/base64" "errors" - "github.com/satori/go.uuid" + "github.com/pborman/uuid" ) var errUUIDForbidden = errors.New("generating UUIDs is forbidden") -var encodedLen = base64.StdEncoding.EncodedLen(uuid.Size) +var encodedLen = base64.StdEncoding.EncodedLen(len(new(uuid.Array))) // NewUUIDFn is a function for creating new UUIDs. type NewUUIDFn func() ([]byte, error) @@ -42,7 +42,7 @@ func NewUUID() ([]byte, error) { // guaranteed to be unique since we may have multiple processes running on the // same host. Elasticsearch uses Flake IDs which ensure uniqueness by requiring // an initial coordination step and we may want to consider doing the same. - uuid := uuid.NewV4().Bytes() + uuid := uuid.NewRandom() buf := make([]byte, encodedLen) base64.StdEncoding.Encode(buf, uuid)