File tree 1 file changed +2
-14
lines changed
1 file changed +2
-14
lines changed Original file line number Diff line number Diff line change @@ -2,12 +2,11 @@ package kallax
2
2
3
3
import (
4
4
"bytes"
5
+ "crypto/rand"
5
6
"database/sql"
6
7
"database/sql/driver"
7
8
"encoding/hex"
8
9
"fmt"
9
- "math/rand"
10
- "sync"
11
10
"time"
12
11
13
12
"github.com/oklog/ulid"
@@ -227,13 +226,6 @@ type Record interface {
227
226
Saveable
228
227
}
229
228
230
- var randPool = & sync.Pool {
231
- New : func () interface {} {
232
- seed := time .Now ().UnixNano () + rand .Int63 ()
233
- return rand .NewSource (seed )
234
- },
235
- }
236
-
237
229
// ULID is an ID type provided by kallax that is a lexically sortable UUID.
238
230
// The internal representation is an ULID (https://github.com/oklog/ulid).
239
231
// It already implements sql.Scanner and driver.Valuer, so it's perfectly
@@ -242,11 +234,7 @@ type ULID uuid.UUID
242
234
243
235
// NewULID returns a new ULID, which is a lexically sortable UUID.
244
236
func NewULID () ULID {
245
- entropy := randPool .Get ().(rand.Source )
246
- id := ULID (ulid .MustNew (ulid .Timestamp (time .Now ()), rand .New (entropy )))
247
- randPool .Put (entropy )
248
-
249
- return id
237
+ return ULID (ulid .MustNew (ulid .Timestamp (time .Now ()), rand .Reader ))
250
238
}
251
239
252
240
// NewULIDFromText creates a new ULID from its string representation. Will
You can’t perform that action at this time.
0 commit comments