mirror of https://github.com/q191201771/lal.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
241 B
Go
17 lines
241 B
Go
6 years ago
|
package unique
|
||
6 years ago
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"sync/atomic"
|
||
|
)
|
||
|
|
||
6 years ago
|
var globalID = uint64(0)
|
||
6 years ago
|
|
||
6 years ago
|
func GenUniqueKey(prefix string) string {
|
||
|
return fmt.Sprintf("%s%d", prefix, genUniqueID())
|
||
6 years ago
|
}
|
||
|
|
||
6 years ago
|
func genUniqueID() uint64 {
|
||
|
return atomic.AddUint64(&globalID, 1)
|
||
6 years ago
|
}
|