Skip to content

Commit c3f8a1f

Browse files
committed
Remove unnecessary UUID counter check that could panic
1 parent 0d25616 commit c3f8a1f

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

common.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,17 @@ const toUpperTable = "\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0e\x0f\x10\x11
2525

2626
var uuidSeed [24]byte
2727
var uuidCounter uint64
28-
var uuidSetup sync.Once
28+
var UUIDSetup sync.Once
2929

3030
// UUID generates an universally unique identifier (UUID)
3131
func UUID() string {
3232
// Setup seed & counter once
33-
uuidSetup.Do(func() {
33+
UUIDSetup.Do(func() {
3434
if _, err := rand.Read(uuidSeed[:]); err != nil {
3535
panic(fmt.Sprintf("utils: failed to seed UUID generator: %v", err))
3636
}
3737
uuidCounter = binary.LittleEndian.Uint64(uuidSeed[:8])
3838
})
39-
if atomic.LoadUint64(&uuidCounter) <= 0 {
40-
panic("utils: UUID counter is not properly initialized")
41-
}
4239
// first 8 bytes differ, taking a slice of the first 16 bytes
4340
x := atomic.AddUint64(&uuidCounter, 1)
4441
uuid := uuidSeed

0 commit comments

Comments
 (0)