From 553a8a732d02ccabb4016b0ac936bbb22ff6ab85 Mon Sep 17 00:00:00 2001 From: Trinh Dinh Bien Date: Thu, 27 Jul 2017 11:15:56 +0700 Subject: [PATCH] update uuidv4 Use uuidv4 generate --- uid/uid.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/uid/uid.go b/uid/uid.go index 71f0cb3..c94138e 100644 --- a/uid/uid.go +++ b/uid/uid.go @@ -1,23 +1,16 @@ package uid import ( - "crypto/rand" "encoding/hex" - "io" + "github.com/satori/go.uuid" ) -// uid returns a unique id. These ids consist of 128 bits from a +// uid returns a v4 unique id. These ids consist of 128 bits from a // cryptographically strong pseudo-random generator and are like uuids, but // without the dashes and significant bits. // // See: http://en.wikipedia.org/wiki/UUID#Random_UUID_probability_of_duplicates func Uid() string { - id := make([]byte, 16) - _, err := io.ReadFull(rand.Reader, id) - if err != nil { - // This is probably an appropriate way to handle errors from our source - // for random bits. - panic(err) - } + id := uuid.NewV1().Bytes() return hex.EncodeToString(id) }