https://github.com/anothermemory/id
Simple ID generator library which can be mocked for testing
https://github.com/anothermemory/id
go golang id identifier ids mock uuid uuid-generator uuid4
Last synced: 5 months ago
JSON representation
Simple ID generator library which can be mocked for testing
- Host: GitHub
- URL: https://github.com/anothermemory/id
- Owner: anothermemory
- License: apache-2.0
- Created: 2018-01-03T17:47:55.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-20T15:39:39.000Z (over 8 years ago)
- Last Synced: 2024-06-21T18:09:06.591Z (about 2 years ago)
- Topics: go, golang, id, identifier, ids, mock, uuid, uuid-generator, uuid4
- Language: Go
- Homepage:
- Size: 31.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Another Memory ID
[](https://goreportcard.com/report/github.com/anothermemory/id)
[](http://godoc.org/github.com/anothermemory/id)
[](https://coveralls.io/github/anothermemory/id)
[](https://github.com/anothermemory/id/releases/latest)
[](LICENSE.md)
[](https://www.codacy.com/app/anothermemory/id)
This library contains interface and set of implementations for generating different identifiers. There are multiple
implementations available. For production usage identifiers must be mostly unique. For testing purposes it's often much
easier to use mocked generator so it will generate the same id each time.
Table of Contents
=================
* [Another Memory ID](#another-memory-id)
* [Getting Started](#getting-started)
* [Prerequisites](#prerequisites)
* [Installing](#installing)
* [See it in action](#see-it-in-action)
* [Mocked ID for testing](#mocked-id-for-testing)
* [Real ID for production](#real-id-for-production)
* [Built With](#built-with)
* [Contributing](#contributing)
* [Versioning](#versioning)
* [Authors](#authors)
* [License](#license)
## Getting Started
### Prerequisites
The project is tested with go 1.9 but probably will work with earlier versions.
### Installing
Simple go get it
```bash
go get github.com/anothermemory/id
```
### See it in action
#### Mocked ID for testing
```go
package id_test
import (
"fmt"
"github.com/anothermemory/id"
)
func Example() {
g := id.NewMock("123")
fmt.Println(g.Generate())
fmt.Println(g.Generate())
// Output:
// 123
// 123
}
```
#### Real ID for production
```go
package id_test
import (
"fmt"
"github.com/anothermemory/id"
)
func Example() {
g := id.NewUUID()
fmt.Println(g.Generate())
fmt.Println(g.Generate())
// Output:
// 2118679c-d6f6-4848-8084-aaab790fd1ae
// 394d79cb-803f-4807-a9bc-00d84d5f9ad3
}
```
## Built With
* [dep](https://github.com/golang/dep) - The dependency management tool for Go
## Contributing
Please read [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for details on our code of conduct, and [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process for submitting pull requests to us.
## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/anothermemory/id/tags).
## Authors
* **Vyacheslav Enis**
See also the list of [contributors](https://github.com/anothermemory/id/contributors) who participated in this project.
## License
This project is licensed under the Apache License 2.0 - see the [LICENSE.md](LICENSE.md) file for details