mirror of https://github.com/status-im/consul.git
Updates hashicorp/go-uuid.
This commit is contained in:
parent
7aedab2407
commit
ccb86d20b0
|
@ -1,6 +1,6 @@
|
|||
# uuid
|
||||
# uuid [![Build Status](https://travis-ci.org/hashicorp/go-uuid.svg?branch=master)](https://travis-ci.org/hashicorp/go-uuid)
|
||||
|
||||
Generates UUID-format strings using purely high quality random bytes.
|
||||
Generates UUID-format strings using high quality, purely random bytes. It can also parse UUID-format strings into their component bytes.
|
||||
|
||||
Documentation
|
||||
=============
|
||||
|
|
|
@ -6,13 +6,21 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
// GenerateRandomBytes is used to generate random bytes of given size.
|
||||
func GenerateRandomBytes(size int) ([]byte, error) {
|
||||
buf := make([]byte, size)
|
||||
if _, err := rand.Read(buf); err != nil {
|
||||
return nil, fmt.Errorf("failed to read random bytes: %v", err)
|
||||
}
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
// GenerateUUID is used to generate a random UUID
|
||||
func GenerateUUID() (string, error) {
|
||||
buf := make([]byte, 16)
|
||||
if _, err := rand.Read(buf); err != nil {
|
||||
return "", fmt.Errorf("failed to read random bytes: %v", err)
|
||||
buf, err := GenerateRandomBytes(16)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return FormatUUID(buf)
|
||||
}
|
||||
|
||||
|
|
|
@ -254,8 +254,10 @@
|
|||
"revisionTime": "2015-02-18T18:19:46Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "mAkPa/RLuIwN53GbwIEMATexams=",
|
||||
"path": "github.com/hashicorp/go-uuid",
|
||||
"revision": "36289988d83ca270bc07c234c36f364b0dd9c9a7"
|
||||
"revision": "64130c7a86d732268a38cb04cfbaf0cc987fda98",
|
||||
"revisionTime": "2016-07-17T02:21:40Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "d9PxF1XQGLMJZRct2R8qVM/eYlE=",
|
||||
|
|
Loading…
Reference in New Issue