业务测试积累

版权声明:东方不败 https://blog.csdn.net/weixin_42498050/article/details/82997914

package helper

import  (

 "time"

 "os"

 "sync"

 "fmt"

)

var autoincrement int64

var mutex sync.Mutex

func GenerateUUID() string {

 mutex.Lock()

 t := time.Now().UnixNano() <<8 + int64(os.Getpid()%16 << 4) + autoincrement%16

 autoincrement += 1

 mutex.Unlock()

 return fmt.Sprintf("%x", t)

}

requestID :

进程ID、纳秒时间戳、加锁

猜你喜欢

转载自blog.csdn.net/weixin_42498050/article/details/82997914