2026-03-31 22:13:34 +10:00
|
|
|
// Copyright 2026 Syntrex Lab. All rights reserved.
|
|
|
|
|
// Use of this source code is governed by an Apache-2.0 license
|
|
|
|
|
// that can be found in the LICENSE file.
|
|
|
|
|
|
2026-03-23 16:45:40 +10:00
|
|
|
package soc
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"crypto/rand"
|
|
|
|
|
"fmt"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// genID generates a collision-safe unique ID with the given prefix.
|
|
|
|
|
// Uses crypto/rand for 8 random hex bytes instead of time.UnixNano
|
|
|
|
|
// to prevent collisions under high concurrency.
|
|
|
|
|
func genID(prefix string) string {
|
|
|
|
|
b := make([]byte, 8)
|
|
|
|
|
_, _ = rand.Read(b)
|
|
|
|
|
return fmt.Sprintf("%s-%x", prefix, b)
|
|
|
|
|
}
|