1
0
mirror of https://github.com/gofiber/fiber.git synced 2025-02-20 22:52:53 +00:00

Make UUID function thread-safe

Co-authored-by: Fenny <fenny@gofiber.io>
Co-authored-by: Kiyon <kiyon@gofiber.io>
This commit is contained in:
ReneWerner87 2020-09-15 10:47:10 +02:00
parent 4995d49921
commit 3028b8d5d8

View File

@ -33,7 +33,7 @@ func UUID() string {
}
uuidCounter = binary.LittleEndian.Uint64(uuidSeed[:8])
})
if uuidCounter <= 0 {
if atomic.LoadUint64(&uuidCounter) <= 0 {
return "00000000-0000-0000-0000-000000000000"
}
// first 8 bytes differ, taking a slice of the first 16 bytes