MushId

package module
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2023 License: MIT Imports: 7 Imported by: 0

README

mushid

unique id generator

list

Usage

  • install
go get github.com/kehiy/mushid/v1
  • use
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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() string

Time : add unix nano timestamp to first part of data (thats simple time is unique in nano seconds) Pid : process id make ids unique in multiple process in one device. MAC address is unique for each device in the world and that makes MushId unique between other devices that generated MushIds.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL