Package goguid is a GUID generation library based on noeqd / snowflake.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo
LICENSE
README
goguid.go
goguid_test.go

README

Package goguid is a GUID generation library based on noeqd / snowflake.
All credit belongs to them!

GUID generation and guarantees (GUID size = 64 bit unsigned)

- time            - 42 bit - millisecond precision (~ 100 years)
- machine id      - 10 bit - max. 1024 machines
- sequence number - 12 bit - rolls over after 4096 id's in one millisecond

Performance
  On a DELL Latitude (i5 2.4GHz) notebook it generates approx. 4 million GUID 
  per second.

Usage

  // Initialize the package
  guid.InitGUID(0, 0)

  for i := int64(0); i < max_guids; i++ {
    if guid.GetGUID() != 0 {
      counter++
    }
  }