Generate Module

Generation module based on Google UUID.
Installation
go get github.com/ankorstore/yokai/generate
Documentation
UUID
This module provides an UuidGenerator interface, allowing to generate UUIDs.
The DefaultUuidGenerator
is based on Google UUID.
package main
import (
"fmt"
"github.com/ankorstore/yokai/generate/uuid"
uuidtest "github.com/ankorstore/yokai/generate/generatetest/uuid"
)
func main() {
// default UUID generator
generator := uuid.NewDefaultUuidGenerator()
fmt.Printf("uuid: %s", generator.Generate()) // uuid: dcb5d8b3-4517-4957-a42c-604d11758561
// test UUID generator (with deterministic value for testing)
testGenerator := uuidtest.NewTestUuidGenerator("test")
fmt.Printf("uuid: %s", testGenerator.Generate()) // uuid: test
}
The module also provides a UuidGeneratorFactory interface, to create
the UuidGenerator instances.
The DefaultUuidGeneratorFactory
generates DefaultUuidGenerator
instances.
package main
import (
"fmt"
"github.com/ankorstore/yokai/generate/uuid"
)
func main() {
// default UUID generator factory
generator := uuid.NewDefaultUuidGeneratorFactory().Create()
fmt.Printf("uuid: %s", generator.Generate()) // uuid: dcb5d8b3-4517-4957-a42c-604d11758561
}