Simple ID generator library which can be mocked for testing
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.
The project is tested with go 1.9 but probably will work with earlier versions.
Simple go get it
go get github.com/anothermemory/id
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
}
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
}
Please read CODE_OF_CONDUCT.md for details on our code of conduct, and CONTRIBUTING.md for details on the process for submitting pull requests to us.
We use SemVer for versioning. For the versions available, see the tags on this repository.
See also the list of contributors who participated in this project.
This project is licensed under the Apache License 2.0 - see the LICENSE.md file for details