lundi 9 mars 2020

Code generating negative numbers while trying to generate unique int64 in golang

I am trying to create unique int64 using the below golang code

unixtimestamp := time.Now().UnixNano()
    node := AppConfig.NodeID << 44
    timestamp := unixtimestamp << 12
    var sequenceID int64
    for sequenceID = 1; sequenceID <= count; sequenceID++ {
        id := node | timestamp | sequenceID
        idList = append(idList, id)
    }

The above code is also generating negative numbers. How do I fix it?




Aucun commentaire:

Enregistrer un commentaire