Skip to content

Commit 55f8a68

Browse files
author
Ferdinand Neman
committed
changed the implementation in ast/unique/Unique.go to straightly uses uuid.NewString() #479 thanks to @xlaohui-txh for raising the issue and @Jonfor for example in your branch
1 parent ca6b212 commit 55f8a68

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

ast/unique/Unique.go

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,11 @@
1515
package unique
1616

1717
import (
18-
"fmt"
19-
"sync"
20-
"time"
21-
)
22-
23-
var (
24-
offset int64 = 0
25-
lastMS int64 = 0
26-
mutex sync.Mutex
18+
"github.com/google/uuid"
2719
)
2820

2921
// NewID will create a new unique ID string for this runtime.
3022
// Uniqueness between system or apps is not necessary.
3123
func NewID() string {
32-
mutex.Lock()
33-
defer mutex.Unlock()
34-
millisUnix := time.Now().Unix()
35-
if lastMS == millisUnix {
36-
offset++
37-
38-
return fmt.Sprintf("%d-%d", lastMS, offset)
39-
}
40-
lastMS = millisUnix
41-
offset = 0
42-
43-
return fmt.Sprintf("%d-%d", lastMS, offset)
24+
return uuid.NewString()
4425
}

0 commit comments

Comments
 (0)