mushid
unique id generator
list
Usage
go get github.com/kehiy/mushid/v1
func main() {
id := mushid.New()
fmt.Println(id) // => "a754b03e2116c97a"
}
- about
mush id is always 16 char length.
- limit
4.7383813 × 10^24 can be written as the absolute number 4,738,381,300,000,000,000,000,000
- importnat
mushid is not recomended for large scale projects!
How MushIds works?
mush ids have 3 parts
1.Time
we use full time (include nano secons) to make a unique string.
2.PID
we use process id to make string unique if two process generated ids in same time in same devices.
3.MAC
we use MAC address to make ids unique if two devices generate ids in same time and same process ids.
crc32 hash function?
we turn result to a crc32 hash to make it fixed length and make MAC, PID and time hide.
pid and MAC make one hash
unix nano second make one hash
and in result we add them to each other.
other programming languages
mush id is already available in other programming languages:
you can add new Implementation and send me a pull request 🍄🤞
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
MIT