Skip to content

Commit

Permalink
Merge pull request #9 from jadr2ddude/default-generator
Browse files Browse the repository at this point in the history
Export DefaultGenerator (formerly generator).

Signed-off-by: Tim Heckman <t@heckman.io>
  • Loading branch information
theckman committed Jul 14, 2018
2 parents 3c44705 + bdebc62 commit 1fe37a0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,35 +43,36 @@ type epochFunc func() time.Time
type hwAddrFunc func() (net.HardwareAddr, error)

var (
global = newRFC4122Generator()
// DefaultGenerator is the default Generator used.
DefaultGenerator = newRFC4122Generator()

posixUID = uint32(os.Getuid())
posixGID = uint32(os.Getgid())
)

// NewV1 returns UUID based on current timestamp and MAC address.
func NewV1() (UUID, error) {
return global.NewV1()
return DefaultGenerator.NewV1()
}

// NewV2 returns DCE Security UUID based on POSIX UID/GID.
func NewV2(domain byte) (UUID, error) {
return global.NewV2(domain)
return DefaultGenerator.NewV2(domain)
}

// NewV3 returns UUID based on MD5 hash of namespace UUID and name.
func NewV3(ns UUID, name string) UUID {
return global.NewV3(ns, name)
return DefaultGenerator.NewV3(ns, name)
}

// NewV4 returns random generated UUID.
func NewV4() (UUID, error) {
return global.NewV4()
return DefaultGenerator.NewV4()
}

// NewV5 returns UUID based on SHA-1 hash of namespace UUID and name.
func NewV5(ns UUID, name string) UUID {
return global.NewV5(ns, name)
return DefaultGenerator.NewV5(ns, name)
}

// Generator provides interface for generating UUIDs.
Expand Down

0 comments on commit 1fe37a0

Please sign in to comment.