Skip to content

Commit

Permalink
feat: added default random source
Browse files Browse the repository at this point in the history
Slight change to the id package to add a default random
source.

Signed-off-by: Richard Case <[email protected]>
  • Loading branch information
richardcase committed Aug 9, 2021
1 parent 7963611 commit dbed674
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/id/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import (
"github.com/oklog/ulid"
)

// New will generate a new unique identifier with a random source based on the unix time now.
// DefaultRand is a random source based on the unix time not.
var DefaultRand = rand.New(rand.NewSource(time.Now().UnixNano())) //nolint:gosec

// New will generate a new unique identifier using the default random source.
func New() (string, error) {
return NewWithRand(rand.New(rand.NewSource(time.Now().UnixNano()))) //nolint:gosec
return NewWithRand(DefaultRand)
}

// NewWithRand will generate a unique identifier with a specific random source.
Expand Down

0 comments on commit dbed674

Please sign in to comment.