Updates hashicorp/go-uuid.

This commit is contained in:
James Phillips 2016-08-09 17:00:16 -07:00
parent 7aedab2407
commit ccb86d20b0
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
3 changed files with 17 additions and 7 deletions

View File

@ -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
=============

View File

@ -6,13 +6,21 @@ import (
"fmt"
)
// GenerateUUID is used to generate a random UUID
func GenerateUUID() (string, error) {
buf := make([]byte, 16)
// 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 "", 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)
}

4
vendor/vendor.json vendored
View File

@ -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=",