Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daegalus/snowflakes
Custom unique identifier tokens
https://github.com/daegalus/snowflakes
Last synced: about 1 month ago
JSON representation
Custom unique identifier tokens
- Host: GitHub
- URL: https://github.com/daegalus/snowflakes
- Owner: daegalus
- Created: 2019-10-11T03:15:54.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-09T17:48:01.000Z (7 months ago)
- Last Synced: 2024-05-09T11:05:06.165Z (6 months ago)
- Language: Go
- Size: 6.84 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Snowflake
Just an experimentation in making my own id generator for use as an identifier to be mapped with users, or for auth, that is short and readable.
The name was chosen as each individual snowflake is different from the other. So it fits with a unique identifier generator.
## Usage
### CLI
Get a new token
```bash
> snowflake
n4Xo9g.r6cguxp6
```Get the timestamp of when the token was generated.
```bash
> snowflake -time n4Xo9g.r6cguxp6
1570762319
```### Library
Generating a new token.
```go
import "github.com/Daegalus/snowflakes"func main() {
token, _err := snowflakes.Snowflake()
fmt.Println(token)
}
```Getting the time from the token.
```go
import "github.com/Daegalus/snowflakes"func main() {
token, _err := snowflakes.Snowflake()
time, _err := snowflakes.GetTimeFromHash()
fmt.Println(time.Unix())
}
```