random

package
v0.6.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RandomRegistry

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

func NewRegistry

func NewRegistry() *RandomRegistry

NewRegistry creates a new instance of regexp registry.

func (*RandomRegistry) LinkHandler

func (rr *RandomRegistry) LinkHandler(fh sprout.Handler) error

LinkHandler links the handler to the registry at runtime.

func (*RandomRegistry) RandAlpha

func (rr *RandomRegistry) RandAlpha(count int) string

RandAlpha generates a random alphabetic string of specified length.

Parameters:

count int - the length of the string to generate.

Returns:

string - the randomly generated alphabetic string.

Example:

{{ 10 | randAlpha }} // Output: "abcdefghij" (output will vary)

func (*RandomRegistry) RandAlphaNumeric

func (rr *RandomRegistry) RandAlphaNumeric(count int) string

RandAlphaNumeric generates a random alphanumeric string of specified length.

Parameters:

count int - the length of the string to generate.

Returns:

string - the randomly generated alphanumeric string.

Example:

{{ 10 | randAlphaNumeric }} // Output: "a1b2c3d4e5" (output will vary)

func (*RandomRegistry) RandAscii

func (rr *RandomRegistry) RandAscii(count int) string

RandAscii generates a random ASCII string (character codes 32 to 126) of specified length.

Parameters:

count int - the length of the string to generate.

Returns:

string - the randomly generated ASCII string.

Example:

{{ 10 | randAscii }} // Output: "}]~>_<:^%" (output will vary)

func (*RandomRegistry) RandBytes

func (rr *RandomRegistry) RandBytes(count int) (string, error)

RandBytes generates a random byte array of specified length and returns it as a base64 encoded string.

Parameters:

count int - the number of bytes to generate.

Returns:

string - the base64 encoded string of the randomly generated bytes.

Example:

{{ 16 | randBytes }} // Output: "c3RhY2thYnVzZSByb2NrcyE=" (output will vary)

func (*RandomRegistry) RandInt

func (rr *RandomRegistry) RandInt(min, max int) int

RandInt generates a random integer between the specified minimum and maximum values (inclusive).

Parameters: - min: the minimum value of the range (inclusive). - max: the maximum value of the range (inclusive).

Returns: - int: the randomly generated integer.

Example: {{ randInt 1 10 }} // Output: 5

func (*RandomRegistry) RandNumeric

func (rr *RandomRegistry) RandNumeric(count int) string

RandNumeric generates a random numeric string of specified length.

Parameters:

count int - the length of the string to generate.

Returns:

string - the randomly generated numeric string.

Example:

{{ 10 | randNumeric }} // Output: "0123456789" (output will vary)

func (*RandomRegistry) RegisterFunctions

func (rr *RandomRegistry) RegisterFunctions(funcsMap sprout.FunctionMap) error

RegisterFunctions registers all functions of the registry.

func (*RandomRegistry) Uid

func (rr *RandomRegistry) Uid() string

Uid returns the unique identifier of the registry.

Jump to

Keyboard shortcuts

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