Skip to content

Commit 0d25616

Browse files
committed
Update UUID function to panic on initialization errors
1 parent 301b082 commit 0d25616

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

common.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"crypto/rand"
99
"encoding/binary"
1010
"encoding/hex"
11+
"fmt"
1112
"os"
1213
"reflect"
1314
"runtime"
@@ -31,12 +32,12 @@ func UUID() string {
3132
// Setup seed & counter once
3233
uuidSetup.Do(func() {
3334
if _, err := rand.Read(uuidSeed[:]); err != nil {
34-
return
35+
panic(fmt.Sprintf("utils: failed to seed UUID generator: %v", err))
3536
}
3637
uuidCounter = binary.LittleEndian.Uint64(uuidSeed[:8])
3738
})
3839
if atomic.LoadUint64(&uuidCounter) <= 0 {
39-
return "00000000-0000-0000-0000-000000000000"
40+
panic("utils: UUID counter is not properly initialized")
4041
}
4142
// first 8 bytes differ, taking a slice of the first 16 bytes
4243
x := atomic.AddUint64(&uuidCounter, 1)

0 commit comments

Comments
 (0)