From 3028b8d5d850b5a83aafd2ee4f529d57ff6c07df Mon Sep 17 00:00:00 2001 From: ReneWerner87 Date: Tue, 15 Sep 2020 10:47:10 +0200 Subject: [PATCH] =?UTF-8?q?=E2=98=94=20Make=20UUID=20function=20thread-saf?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Fenny Co-authored-by: Kiyon --- utils/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/common.go b/utils/common.go index b9dd0c45..e045870b 100644 --- a/utils/common.go +++ b/utils/common.go @@ -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