Created
May 10, 2022 04:07
-
-
Save gmarcial/65bdc21a42d5cdbc97ae48f4703240f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package uuid | |
import ( | |
googleUUID "github.com/google/uuid" | |
) | |
// Generator ... | |
type Generator interface { | |
NewUUID() (string, error) | |
} | |
// uuidGenerator ... | |
type uuidGenerator struct{} | |
// NewUUIDGenerator ... | |
func NewUUIDGenerator() Generator { | |
googleUUID.EnableRandPool() | |
return uuidGenerator{} | |
} | |
// NewUUID ... | |
func (generator uuidGenerator) NewUUID() (string, error) { | |
uuidGenerated, err := googleUUID.NewRandom() | |
if err != nil { | |
return "", err | |
} | |
return uuidGenerated.String(), err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment