wordgen

package module
v0.0.0-...-1dcbb87 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func INITIALIZE_VARS_DO_NOT_CALL_INSIDE_INIT

func INITIALIZE_VARS_DO_NOT_CALL_INSIDE_INIT()

INITIALIZE_VARS_DO_NOT_CALL_INSIDE_INIT initializes all the package variables to reflect the backing-variable. This call is optional, but if you do not call it, then you must not attempt to access or set the exported package variables until an exported function or method is called first (the functions and methods automatically call this).

NOTE: This function must not be called from within an init() function.

Types

type Generator

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

Generator produces strings containing random words that conform to a provided pattern.

func New

func New(pattern string) Generator

New returns a Generator that is designed to be used repeatedly for a provided pattern.

The pattern can contain '#' (base-10 digit), 'h'/'H' (hexadecimal digit), 'n'/'N'/'Ñ' (nouns), 'a'/'A'/'Ã' (adjectives), 'v'/'V'/'Ṽ' (verbs) and '*' (any word). '\' can be used to escape the special characters. Upper-case characters generate upper-case words. Tilde characters generate title case words.

Example

`学中文:n-v-a-n` could return "学中文:dog-ran-red-banana"

func (Generator) Error

func (g Generator) Error() string

Error must not be used! It is only defined so that the fmt package can "pretty print" the Generator since the Stringer interface can't be implemented.

NOTE: Do not use Generator as an error.

func (Generator) String

func (g Generator) String(max ...any) string

String generates a random string that conforms to the provided pattern.

NOTE: When setting an optional max string length, it should be substantially larger than the theoretical minimum to prevent a potential infinite loop. A context can be supplied as the first argument to provide a deadline. If the deadline is reached, an empty string is returned.

Jump to

Keyboard shortcuts

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