generate

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2024 License: MIT

README

Generate Module

ci go report codecov PkgGoDev

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
}

Directories

Path Synopsis
generatetest

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL