github.com/Asutorufa/yuhaiin@v0.3.6-0.20240502055049-7984da7023a0/pkg/utils/id/id.go (about)

     1  package id
     2  
     3  import "sync/atomic"
     4  
     5  type IDGenerator struct {
     6  	node atomic.Uint64
     7  }
     8  
     9  func (i *IDGenerator) Generate() (id uint64) {
    10  	return i.node.Add(1)
    11  }