https://github.com/bndw/id
A lightweight wrapper for generating common identifiers
https://github.com/bndw/id
namegenerator shortid uuid
Last synced: 8 months ago
JSON representation
A lightweight wrapper for generating common identifiers
- Host: GitHub
- URL: https://github.com/bndw/id
- Owner: bndw
- Created: 2020-03-03T06:03:56.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-01-21T04:19:47.000Z (over 5 years ago)
- Last Synced: 2025-02-05T09:53:51.977Z (over 1 year ago)
- Topics: namegenerator, shortid, uuid
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# id
A lightweight wrapper for generating common identifiers.
```go
package main
import (
"github.com/bndw/id"
)
func main() {
_ = id.Short() // => "tUn5nCxGR"
_ = id.ShortPrefix("foo_") // => "foo_tUn5nCxGR"
_ = id.UUID() // => "5c5aa201-e466-4f64-bac8-5cacd39160b5"
_ = id.UUIDPrefix("foo_") // => "foo_5c5aa201-e466-4f64-bac8-5cacd39160b5"
_ = id.Name() // => "happy_dubinsky"
_ = id.NamePrefix("foo_") // => "foo_happy_dubinsky"
}
```
| Function | Description | Example | Source |
| -------- | ----------- | ------- | ------ |
| `id.Short` | Short, fully unique, non-sequential, URL friendly Ids | `tUn5nCxGR` | [teris-io/shortid] |
| `id.ShortPrefix` | Prefixed, short, fully unique, non-sequential, URL friendly Ids | `foo_tUn5nCxGR` | [teris-io/shortid] |
| `id.UUID` | UUID (v4) | `5c5aa201-e466-4f64-bac8-5cacd39160b5`| [google/uuid] |
| `id.UUIDPrefix` | Prefixed UUID (v4) | `foo_5c5aa201-e466-4f64-bac8-5cacd39160b5`| [google/uuid] |
| `id.Name` | Docker-style names | `happy_dubinsky`| [moby/namegenerator] |
| `id.NamePrefix` | Docker-style names | `foo_happy_dubinsky`| [moby/namegenerator] |
[teris-io/shortid]: https://github.com/teris-io/shortid
[google/uuid]: https://github.com/google/uuid
[moby/namegenerator]: https://github.com/moby/moby/tree/master/pkg/namesgenerator