aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/go-uuid/uuid.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/go-uuid/uuid.go')
-rw-r--r--vendor/github.com/hashicorp/go-uuid/uuid.go16
1 files changed, 12 insertions, 4 deletions
diff --git a/vendor/github.com/hashicorp/go-uuid/uuid.go b/vendor/github.com/hashicorp/go-uuid/uuid.go
index 322b522..ff9364c 100644
--- a/vendor/github.com/hashicorp/go-uuid/uuid.go
+++ b/vendor/github.com/hashicorp/go-uuid/uuid.go
@@ -6,13 +6,21 @@ import (
6 "fmt" 6 "fmt"
7) 7)
8 8
9// GenerateUUID is used to generate a random UUID 9// GenerateRandomBytes is used to generate random bytes of given size.
10func GenerateUUID() (string, error) { 10func GenerateRandomBytes(size int) ([]byte, error) {
11 buf := make([]byte, 16) 11 buf := make([]byte, size)
12 if _, err := rand.Read(buf); err != nil { 12 if _, err := rand.Read(buf); err != nil {
13 return "", fmt.Errorf("failed to read random bytes: %v", err) 13 return nil, fmt.Errorf("failed to read random bytes: %v", err)
14 } 14 }
15 return buf, nil
16}
15 17
18// GenerateUUID is used to generate a random UUID
19func GenerateUUID() (string, error) {
20 buf, err := GenerateRandomBytes(16)
21 if err != nil {
22 return "", err
23 }
16 return FormatUUID(buf) 24 return FormatUUID(buf)
17} 25}
18 26