generator

package
v0.0.0-...-73e1fb8 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package generator defines GeneratorInterface interface and implements some random value generators.

Index

Constants

View Source
const (
	Alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	Numerals = "0123456789"
	Symbols  = "~!@#$%^&*()-_+={}[]\\|<,>.?/\"';:`"
	ASCII    = Alphabet + Numerals + Symbols
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ExpressionValueGenerator

type ExpressionValueGenerator struct {
	// contains filtered or unexported fields
}

ExpressionValueGenerator implements Generator interface. It generates random string based on the input expression. The input expression is a string, which may contain "[a-zA-Z0-9]{length}" constructs, defining range and length of the result random characters.

Examples:

from | value ----------------------------- "test[0-9]{1}x" | "test7x" "[0-1]{8}" | "01001100" "0x[A-F0-9]{4}" | "0xB3AF" "[a-zA-Z0-9]{8}" | "hW4yQU5i"

TODO: Support more regexp constructs.

func NewExpressionValueGenerator

func NewExpressionValueGenerator(seed *rand.Rand) ExpressionValueGenerator

NewExpressionValueGenerator creates new ExpressionValueGenerator.

func (ExpressionValueGenerator) GenerateValue

func (g ExpressionValueGenerator) GenerateValue(expression string) (interface{}, error)

GenerateValue generates random string based on the input expression. The input expression is a pseudo-regex formatted string. See ExpressionValueGenerator for more details.

type Generator

type Generator interface {
	GenerateValue(expression string) (interface{}, error)
}

Generator is an interface for generating random values from an input expression

Directories

Path Synopsis
Package examples demonstrates possible implementation of some random value generators.
Package examples demonstrates possible implementation of some random value generators.

Jump to

Keyboard shortcuts

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