IDE>> id>> 返回
项目作者: anothermemory

项目描述 :
Simple ID generator library which can be mocked for testing
高级语言: Go
项目地址: git://github.com/anothermemory/id.git
创建时间: 2018-01-03T17:47:55Z
项目社区:https://github.com/anothermemory/id

开源协议:Apache License 2.0

下载


Another Memory ID

Go Report Card
Go Doc
Coveralls github
Release
license
Codacy grade

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

Getting Started

Prerequisites

The project is tested with go 1.9 but probably will work with earlier versions.

Installing

Simple go get it

  1. go get github.com/anothermemory/id

See it in action

Mocked ID for testing

  1. package id_test
  2. import (
  3. "fmt"
  4. "github.com/anothermemory/id"
  5. )
  6. func Example() {
  7. g := id.NewMock("123")
  8. fmt.Println(g.Generate())
  9. fmt.Println(g.Generate())
  10. // Output:
  11. // 123
  12. // 123
  13. }

Real ID for production

  1. package id_test
  2. import (
  3. "fmt"
  4. "github.com/anothermemory/id"
  5. )
  6. func Example() {
  7. g := id.NewUUID()
  8. fmt.Println(g.Generate())
  9. fmt.Println(g.Generate())
  10. // Output:
  11. // 2118679c-d6f6-4848-8084-aaab790fd1ae
  12. // 394d79cb-803f-4807-a9bc-00d84d5f9ad3
  13. }

Built With

  • dep - The dependency management tool for Go

Contributing

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.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

  • Vyacheslav Enis

See also the list of contributors who participated in this project.

License

This project is licensed under the Apache License 2.0 - see the LICENSE.md file for details