Updates hashicorp/go-uuid.
This commit is contained in:
parent
2e931733d0
commit
eceb58fff5
|
@ -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
|
Documentation
|
||||||
=============
|
=============
|
||||||
|
|
|
@ -6,13 +6,21 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GenerateUUID is used to generate a random UUID
|
// GenerateRandomBytes is used to generate random bytes of given size.
|
||||||
func GenerateUUID() (string, error) {
|
func GenerateRandomBytes(size int) ([]byte, error) {
|
||||||
buf := make([]byte, 16)
|
buf := make([]byte, size)
|
||||||
if _, err := rand.Read(buf); err != nil {
|
if _, err := rand.Read(buf); err != nil {
|
||||||
return "", fmt.Errorf("failed to read random bytes: %v", err)
|
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, err := GenerateRandomBytes(16)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
return FormatUUID(buf)
|
return FormatUUID(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -254,8 +254,10 @@
|
||||||
"revisionTime": "2015-02-18T18:19:46Z"
|
"revisionTime": "2015-02-18T18:19:46Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"checksumSHA1": "mAkPa/RLuIwN53GbwIEMATexams=",
|
||||||
"path": "github.com/hashicorp/go-uuid",
|
"path": "github.com/hashicorp/go-uuid",
|
||||||
"revision": "36289988d83ca270bc07c234c36f364b0dd9c9a7"
|
"revision": "64130c7a86d732268a38cb04cfbaf0cc987fda98",
|
||||||
|
"revisionTime": "2016-07-17T02:21:40Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "d9PxF1XQGLMJZRct2R8qVM/eYlE=",
|
"checksumSHA1": "d9PxF1XQGLMJZRct2R8qVM/eYlE=",
|
||||||
|
|
Loading…
Reference in New Issue