Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions common.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,10 @@ func UUID() string {
// Setup seed & counter once
uuidSetup.Do(func() {
if _, err := rand.Read(uuidSeed[:]); err != nil {
panic(fmt.Sprintf("utils: failed to seed UUID generator: %v", err))
panic(fmt.Errorf("utils: failed to seed UUID generator: %w", err))
}
uuidCounter = binary.LittleEndian.Uint64(uuidSeed[:8])
})
if atomic.LoadUint64(&uuidCounter) <= 0 {
panic("utils: UUID generator not properly seeded")
}
// first 8 bytes differ, taking a slice of the first 16 bytes
x := atomic.AddUint64(&uuidCounter, 1)
_uuid := uuidSeed
Expand Down Expand Up @@ -94,7 +91,7 @@ func UUID() string {
func UUIDv4() string {
token, err := uuid.NewRandom()
if err != nil {
panic(fmt.Sprintf("utils: failed to generate secure UUID: %v", err))
panic(fmt.Errorf("utils: failed to generate secure UUID: %w", err))
}
return token.String()
}
Expand Down
Loading