Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/newm4n/go-jenius-unique
Unique ID generator that really unique but short.
https://github.com/newm4n/go-jenius-unique
Last synced: about 1 month ago
JSON representation
Unique ID generator that really unique but short.
- Host: GitHub
- URL: https://github.com/newm4n/go-jenius-unique
- Owner: newm4n
- License: apache-2.0
- Created: 2018-04-13T12:56:57.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-04-13T14:12:55.000Z (over 6 years ago)
- Last Synced: 2024-06-20T05:03:58.167Z (5 months ago)
- Language: Go
- Size: 8.79 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# README
Generate Unique ID.
```
go get github.com/newm4n/go-jenius-unique
```## HOW ???
You should read the test class `idgen_test.go` on how to use the library.
TL;DR :
```
import (
"jeniusunique"
)
...
unique24CharString := jeniusunique.GetUniqueGenInstance().NewXReferenceNo(24)
...
```
`NewXReferenceNo` accept an number parameter which is the length of string to be generated.## HOW YOU DO IT ?
```
nn = last known nano second time stamp in int64
i = mac-address in int64func GetUniqueGenInstance(l) string
n = nano second timestamp in int64
c = 0
if n == nn {
c++
unique = n xor i xor c
} else {
c = 0
unique = n xor i xor 0
}
nn = n
if len(unique) < l {
append unique with random char until it has len == l
}
}
```