gengo

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: MIT Imports: 6 Imported by: 0

README

gengo logo

gengo — Random Data Generator for Go

build Go Reference Go Report Card Go Version GitHub release

gengo is a zero-dependency Go library for generating random test data — strings, numbers, dates, booleans, and words — with a single function call. No configuration, no boilerplate. Just fast, reliable random data whenever you need it.

Why gengo?

Generating realistic test data in Go usually means writing repetitive helper functions or pulling in heavy dependencies. gengo solves this with a clean, idiomatic API that covers the most common use cases out of the box:

  • One function call to generate any random value
  • Zero external dependencies — only the Go standard library
  • Blazing fast — single-digit-nanosecond generation for primitive types on modern hardware
  • Safe by default — built-in overflow protection, size limits, and uniform distribution

Installation

go get -u github.com/FlavioCFOliveira/gengo

Requires Go 1.26 or later.


Quick Start

package main

import (
    "fmt"
    "github.com/FlavioCFOliveira/gengo"
)

func main() {
    // Random alphanumeric string — handy for test fixtures and IDs
    fmt.Println(gengo.StringAlphanumeric(20))
    // Output: k9mP2vLxQr5tWnB8aJcT

    // Random integer in a custom range
    fmt.Println(gengo.IntBetween(1, 100))
    // Output: 42

    // Random date anywhere in history or the future
    fmt.Println(gengo.Date())
    // Output: 1847-03-15 08:23:17 UTC
}

Table of Contents


String Generation

All string functions accept a length parameter — the number of bytes, capped at 1 MB. Pick a predefined type or pass your own character set. String generation is byte-oriented, so custom character sets should contain only single-byte (ASCII) characters; multibyte input (emoji, accents, CJK) produces invalid UTF-8.

Custom and Variable-Length Strings
// Generate from a custom character set
custom := gengo.String(10, "ABC123")
// Output: C1BA3C2A1B

// Generate a string with a random length between min and max
variable := gengo.StringBetween(5, 15, gengo.Alphanumeric)
Predefined String Types
Function Output characters Example
StringAllChars(n) Letters + numbers + symbols aB3$kP9@mQ
StringAlphanumeric(n) Letters + numbers xK8pM2vLqR
StringAlphabetic(n) Upper and lower case letters bGtRvNmKlP
StringAlphabeticUppercase(n) A–Z only XKMTPQRLVN
StringAlphabeticLowercase(n) a–z only mkptqrvbgs
StringNumeric(n) Digits 0–9 only 8472936105
StringHexadecimal(n) Hex digits 0–9, A–F A7F3B9E2D1
StringSymbols(n) Special characters only @#$%&*()-_
Security: Not for Passwords or Secrets

[!WARNING] gengo is not cryptographically secure. It is built on math/rand/v2, whose output is fast but predictable and therefore unsuitable for any security-sensitive purpose. Never use gengo to generate passwords, API tokens, session IDs, encryption keys, salts, or any other secret — the results are guessable. For secrets, use Go's crypto/rand package instead.

See SECURITY.md for the full security policy and how to report a vulnerability.

Common Use Cases
// Short, human-readable identifier for test fixtures
id := gengo.StringAlphanumeric(8)
// Output: xK8pM2vL

// Random label for seeding a database column
label := gengo.StringAlphabetic(12)
// Output: bGtRvNmKlPqX

// Random hex value for non-secret test data (e.g. a fake colour code)
hex := gengo.StringHexadecimal(6)
// Output: A7F3B9

Number Generation

Integers

Every integer type comes in two flavours:

  • Type() — full range of that type
  • TypeBetween(min, max) — your custom range (min and max are swapped automatically if reversed)
Type Function Full Range Range example
int8 Int8() −128 to 127 Int8Between(-50, 50)
int16 Int16() −32 768 to 32 767 Int16Between(100, 1000)
int32 Int32() ±2 billion Int32Between(0, 999999)
int64 Int64() ±9 quintillion Int64Between(0, time.Now().Unix())
int Int() Platform dependent IntBetween(1, 100)
uint8 / byte Uint8() / Byte() 0 to 255 Uint8Between(0, 255)
uint16 Uint16() 0 to 65 535 Uint16Between(1000, 5000)
uint32 Uint32() 0 to 4 billion Uint32Between(0, 100000)
uint64 Uint64() 0 to 18 quintillion Uint64Between(0, math.MaxUint32)
// Random age between 18 and 100
age := gengo.IntBetween(18, 100)

// Random percentage (0–100)
percent := gengo.Uint8Between(0, 100)

// Random unprivileged port number
port := gengo.Uint16Between(1024, 65535)

// Random byte for binary data
b := gengo.Byte()
Floating Point
Function Range Description
Float32() (0, MaxFloat32) Positive values only — use Float32Between for negatives or a custom range
Float32Between(min, max) Custom Bounded float32
Float64() (0, MaxFloat64) Positive values only — use Float64Between for negatives or a custom range
Float64Between(min, max) Custom Bounded float64
// Random price for e-commerce testing
price := gengo.Float64Between(0.99, 999.99)

// Random percentage with decimal precision
percentage := gengo.Float32Between(0.0, 100.0)

// Random geographic coordinates
lat := gengo.Float64Between(-90.0, 90.0)
lng := gengo.Float64Between(-180.0, 180.0)
Complex Numbers
Function Description
Complex64() Random complex64 with random real and imaginary parts
Complex64Between(rMin, rMax, iMin, iMax) Custom ranges for both parts
Complex128() Random complex128 with random real and imaginary parts
Complex128Between(rMin, rMax, iMin, iMax) Custom ranges for both parts
// Random complex number
c := gengo.Complex64()
// Output: (12.34+56.78i)

// Bounded unit circle range
c = gengo.Complex64Between(-1.0, 1.0, -1.0, 1.0)
// Output: (0.45-0.92i)

Date & Time

Generate random timestamps for testing date-sensitive logic, filling databases with realistic data, or simulating time-based events.

Function Description Range
Date() Random date and time Year 1 to 9999
UnixDate() Random Unix timestamp 1970 to 2038 (32-bit range)
DateBetween(start, end) Random date within a specific range Custom

All date functions work at whole-second granularity and return UTC times with a zero sub-second component. For DateBetween, the bounds' sub-second parts are ignored; as a special case, when start and end fall within the same second, start is returned unchanged.

// Random historical or future date
d := gengo.Date()
// Output: 1847-03-15 08:23:17 UTC

// Random date in the Unix epoch range
d = gengo.UnixDate()
// Output: 1995-11-30 14:45:02 UTC

// Random date within a custom range
start := time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC)
end := time.Date(2024, 12, 31, 0, 0, 0, 0, time.UTC)
d = gengo.DateBetween(start, end)
// Output: 2022-07-14 09:33:45 UTC

// Random birthdate for someone aged 18 to 65
now := time.Now()
minAge := now.AddDate(-65, 0, 0)
maxAge := now.AddDate(-18, 0, 0)
birthdate := gengo.DateBetween(minAge, maxAge)

Booleans

// 50/50 coin flip
if gengo.Bool() {
    fmt.Println("Heads")
} else {
    fmt.Println("Tails")
}

// Randomly toggle a feature flag in tests
if gengo.Bool() {
    enableNewFeature()
}

Words & Text

Generate random words for populating text fields, testing search functionality, or seeding databases with human-readable content.

Single Word
// Random word between 2 and 30 lowercase letters
word := gengo.Word()
// Output: galhjhyqxfmvwqxqywuigohxhvclk
Words by Length Category
Category Length Example output
SmallLengthWord 1–4 chars cat, dog, sun
MediumLengthWords 5–8 chars house, garden
BigLengthWords 9–30 chars wonderful, beautiful
small  := gengo.WordByLengthType(gengo.SmallLengthWord)
medium := gengo.WordByLengthType(gengo.MediumLengthWords)
big    := gengo.WordByLengthType(gengo.BigLengthWords)
Multiple Words
// Generate a slice of random words
words := gengo.Words(5)
// Output: [ok then computer building wonderful]

// Natural-language-like distribution (from WordLengthRatio, 13/26/11 of 50):
// ~26% small words (1–4 chars)
// ~52% medium words (5–8 chars)
// ~22% big words (9–30 chars)

European Portuguese Words (pt-PT)

Beyond the ASCII words above, gengo generates European-Portuguese (pt-PT) words with full grammatical inflection — handy for seeding realistic Portuguese text, testing search and collation, or filling forms.

Words fall into two families:

  • Open classes (noun, adjective, verb, adverb) are generated pseudo-words: morphologically well-formed, phonotactically valid, and correctly accented, but not guaranteed to be real dictionary entries.
  • Closed classes (article, pronoun, numeral, preposition, conjunction, interjection) are real, curated words drawn uniformly from hand-checked lists.

Every result is always lowercase and valid UTF-8. No function ever returns an error or panics.

Inflection Options

Inflection is controlled by six enums. Each has an Any… zero value that means "choose a valid value at random"; the length category adds its own AnyLengthWord zero value that means "any length".

Enum Zero value (random) Concrete values
Gender AnyGender Masculine, Feminine
Number AnyNumber Singular, Plural
Degree AnyDegree Positive, Superlative (synthetic absolute superlative, -íssimo)
Mood AnyMood Indicative, Subjunctive, ImperativeAffirmative, ImperativeNegative, Infinitive, Gerund, Participle
Tense AnyTense Present, Imperfect, Preterite, Future, Conditional
Person AnyPerson First, Second, Third
LengthTypeWords AnyLengthWord SmallLengthWord, MediumLengthWords, BigLengthWords

A grammatically impossible request never panics: it normalizes to the nearest valid form (for example, a second-person-plural verb becomes third-person plural, matching current pt-PT usage), and a length category too small for the chosen word is widened upward, never downward.

Open Classes (generated pseudo-words)
// Nouns — random gender, number, and length, or fully specified
n := gengo.NounPT()
n = gengo.NounPTOf(gengo.Feminine, gengo.Plural, gengo.MediumLengthWords)

// Adjectives — including the synthetic superlative (-íssimo)
a := gengo.AdjectivePT()
a = gengo.AdjectivePTOf(gengo.Masculine, gengo.Singular, gengo.Superlative, gengo.AnyLengthWord)

// Verbs — any mood, tense, person, and number
v := gengo.VerbPT()
v = gengo.VerbPTOf(gengo.Indicative, gengo.Present, gengo.First, gengo.Singular, gengo.AnyLengthWord)

// Adverbs — productive -mente forms (invariable)
adv := gengo.AdverbPT()
adv = gengo.AdverbPTByLengthType(gengo.MediumLengthWords)
Closed Classes (real curated words)

Closed-class selectors return genuine pt-PT words in European spelling. They take no length parameter, because the length concept does not apply.

art  := gengo.ArticlePT()      // e.g. "a", "do", "pelas"
pron := gengo.PronounPT()      // e.g. "eu", "aquilo", "cujo"
num  := gengo.NumeralPT()      // e.g. "três", "primeiro", "meio"
prep := gengo.PrepositionPT()  // e.g. "de", "para", "perante"
conj := gengo.ConjunctionPT()  // e.g. "e", "mas", "porque"
intj := gengo.InterjectionPT() // e.g. "olá", "caramba", "psiu"
Any Word

WordPT returns a random word of a random class, following a natural distribution across word classes. WordsPT returns a slice of them.

w := gengo.WordPT()                                // any class, any length
w = gengo.WordPTByLengthType(gengo.BigLengthWords) // length applies to open classes only
list := gengo.WordsPT(5)                           // slice of 5 random pt-PT words
Reproducible pt-PT Output

Every function above is also a *Generator method, so a seeded generator produces a reproducible sequence — ideal for golden tests:

g := gengo.New(7)
fmt.Println(g.NounPTOf(gengo.Feminine, gengo.Plural, gengo.MediumLengthWords))
fmt.Println(g.VerbPTOf(gengo.Indicative, gengo.Present, gengo.First, gengo.Singular, gengo.AnyLengthWord))
// Same seed → same words, every run.

Reproducible Output

By default, gengo's package-level functions draw from Go's global math/rand/v2 source, which is automatically seeded — great for variety, but the output cannot be reproduced. When you need a deterministic sequence (for example, to reproduce a failing test), create a seeded Generator:

// Same seed → same sequence, every run
g := gengo.New(42)
fmt.Println(g.IntBetween(1, 100))            // deterministic for seed 42
fmt.Println(g.String(8, gengo.Alphanumeric)) // deterministic for seed 42

// A second generator with the same seed reproduces the sequence exactly
g2 := gengo.New(42)
// g2 yields the identical sequence as g

A Generator exposes a method for every package-level function (g.Int8(), g.Float64Between(...), g.Date(), g.Word(), and so on), so it is a drop-in replacement when you need reproducibility. For full control over the underlying algorithm, build one from any math/rand/v2 source:

import "math/rand/v2"

g := gengo.NewSource(rand.NewPCG(1, 2))

A Generator is not safe for concurrent use by multiple goroutines (it wraps a math/rand/v2.Rand). Use one generator per goroutine, or the package-level functions — which are safe for concurrent use — when you don't need reproducibility.


Character Sets

Use these built-in constants to build your own character sets or combine them for custom string generation.

Constant Characters Size
AllChars a-zA-Z0-9!@#$%... 87
Alphanumeric a-zA-Z0-9 62
Alphabetic a-zA-Z 52
AlphabeticUppercase A-Z 26
AlphabeticLowercase a-z 26
Numeric 0-9 10
Hexadecimal 0-9A-F 16
Symbols !@#$%... 25
// Letters and underscores — safe for usernames
usernameSafe := gengo.AlphabeticLowercase + "_"
name := gengo.String(12, usernameSafe)

// URL-safe slugs
urlSafe := gengo.Alphanumeric + "-_"
slug := gengo.String(20, urlSafe)

// Fun custom charset (ASCII) — e.g. DNA bases
dna := "ACGT"
sequence := gengo.String(20, dna)
// Output: GATTACAGATTACAGGCTAG

Safety & Limits

gengo is designed to be safe to use in production code and CI pipelines without any extra configuration:

  • String length cap: Maximum 1 MB (MaxStringLength) prevents accidental memory exhaustion
  • Automatic range correction: All Between functions swap min and max if they are reversed
  • Overflow protection: Integer calculations use wider intermediate types to prevent wrap-around
  • Uniform distribution: Backed by math/rand/v2 for statistically unbiased results

Performance

Benchmarks run on an AMD Ryzen 9 5900HX (Go 1.26.2, -benchtime 5s). See make bench to reproduce on your machine.

Operation ns/op
IntBetween ~7.8
Float64 ~5.8
String (8 chars) ~27.8
Date ~7.4
Uint64 ~4.8

String functions allocate exactly once per call, for the returned string, at every length. On Go 1.27.1 (same machine) the single-allocation rewrite of String made lengths above 32 bytes 13–16% faster single-threaded (7–16% for Generator.String) and 31–41% faster under 8–16 concurrent goroutines. It also measured String with an 8-byte result 3–6% slower. The code for lengths up to 32 bytes is unchanged; the slowdown comes from code layout.

For the full benchmark report and detailed test results, see BENCHMARKS.md and TEST_REPORT.md.


Contributing

Contributions are welcome! See CONTRIBUTING.md for the build, test, and lint workflow, the coding conventions, and the pull-request process. For security issues, follow SECURITY.md.


License

Released under the MIT License.

Documentation

Overview

Package gengo provides a simple and practical way to generate random data structures. It offers a zero-dependency API for generating random values of standard Go types including integers, floats, complex numbers, strings, booleans, dates, and words.

The package-level functions draw from the global math/rand/v2 source and are safe for concurrent use. For reproducible output, use a seeded Generator created with New or NewSource.

gengo is not cryptographically secure: it is built on math/rand/v2, whose output is predictable. Do not use it for passwords, tokens, keys, or any other secret; use crypto/rand instead.

Index

Examples

Constants

View Source
const (
	AllChars            string = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%&*()-_=+[]{}<>?/|\^~`
	Alphanumeric        string = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`
	Alphabetic          string = `abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`
	AlphabeticUppercase string = `ABCDEFGHIJKLMNOPQRSTUVWXYZ`
	AlphabeticLowercase string = `abcdefghijklmnopqrstuvwxyz`
	Numeric             string = `0123456789`
	Hexadecimal         string = `0123456789ABCDEF`
	Symbols             string = `!@#$%&*()-_=+[]{}<>?/|\^~`
	MaxStringLength     uint32 = 1024 * 1024 // 1MB maximum string length
)

Character sets available for string generation.

View Source
const WordLengthRatio = `11111111111112222222222222222222222222233333333333`

WordLengthRatio is the sampling table that defines the natural length distribution used by Words. Each digit selects a length category ('1' small, '2' medium, '3' big); the proportions (13/26/11 of 50) yield roughly 26% small, 52% medium, and 22% big words.

Variables

This section is empty.

Functions

func AdjectivePT added in v0.2.0

func AdjectivePT() string

AdjectivePT returns a random European-Portuguese (pt-PT) pseudo-adjective with a random gender, number, degree and length. It is exact sugar for AdjectivePTOf(AnyGender, AnyNumber, AnyDegree, AnyLengthWord). The result is a lowercase, valid-UTF-8 word that follows pt-PT adjective morphology and graphic accentuation; it is a plausible invented word, not guaranteed to be a real dictionary entry.

AdjectivePT draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines. For reproducible output, use a seeded Generator (New or NewSource) and its AdjectivePT method.

func AdjectivePTOf added in v0.2.0

func AdjectivePTOf(g Gender, n Number, d Degree, l LengthTypeWords) string

AdjectivePTOf returns a random pt-PT pseudo-adjective inflected for gender g, number n and degree d, within length category l. Each option's Any zero value (AnyGender, AnyNumber, AnyDegree, AnyLengthWord) selects a random valid value. A gender-inflecting ending realizes the requested gender directly; a gender-invariable ending serves either request with one form. Degree Positive yields the base adjective; Superlative yields the synthetic absolute superlative -íssimo/-íssima, inflected for gender and number. When l cannot hold any adjective of the chosen ending and degree, l is normalized upward to the smallest category that can (length is never normalized downward); in particular a Superlative never fits SmallLengthWord and normalizes up. The result is always lowercase and valid UTF-8; the function never returns an error and never panics.

AdjectivePTOf draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines.

Example

ExampleAdjectivePTOf generates a pt-PT pseudo-adjective in the synthetic absolute superlative degree. The masculine singular superlative always ends in the -íssimo suffix.

package main

import (
	"fmt"

	"github.com/FlavioCFOliveira/gengo"
)

func main() {
	g := gengo.New(7)
	fmt.Println(g.AdjectivePTOf(gengo.Masculine, gengo.Singular, gengo.Superlative, gengo.AnyLengthWord))
}
Output:
racantíssimo

func AdverbPT added in v0.2.0

func AdverbPT() string

AdverbPT returns a random European-Portuguese (pt-PT) pseudo-adverb: a productive -mente adverb of random length. It is exact sugar for AdverbPTByLengthType(AnyLengthWord). The result is a lowercase, valid-UTF-8 word formed from the feminine singular of a generated adjective plus -mente; it is invariable and carries no graphic accent. It is a plausible invented word, not guaranteed to be a real dictionary entry.

AdverbPT draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines. For reproducible output, use a seeded Generator (New or NewSource) and its AdverbPT method.

Example

ExampleAdverbPT generates a pt-PT pseudo-adverb. Every generated adverb is a productive -mente form and is invariable.

package main

import (
	"fmt"

	"github.com/FlavioCFOliveira/gengo"
)

func main() {
	g := gengo.New(6)
	fmt.Println(g.AdverbPT())
}
Output:
dilrantemente

func AdverbPTByLengthType added in v0.2.0

func AdverbPTByLengthType(l LengthTypeWords) string

AdverbPTByLengthType returns a random pt-PT productive -mente adverb within length category l. AnyLengthWord (the zero value) selects a random valid length. A -mente adverb is invariable — it does not inflect for gender, number, or degree — so length is its only option. When l cannot hold any -mente adverb (its shortest form exceeds the category ceiling), l is normalized upward to the smallest category that can (length is never normalized downward); in particular an adverb never fits SmallLengthWord and normalizes up. The result is always lowercase and valid UTF-8; the function never returns an error and never panics.

AdverbPTByLengthType draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines.

func ArticlePT added in v0.2.0

func ArticlePT() string

ArticlePT returns a real European-Portuguese (pt-PT) article, selected uniformly at random from the curated, exhaustive list of single-word articles (definite, indefinite, and single-word preposition+article contractions such as "do", "no", "pelo", "à"). The result is a real, lowercase, correctly accented pt-PT word, never invented; the length concept does not apply to closed classes, so ArticlePT takes no length option.

ArticlePT draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines. For reproducible output, use a seeded Generator (New or NewSource) and its ArticlePT method.

func Bool added in v0.0.18

func Bool() bool

Bool returns a random boolean value.

func Byte added in v0.0.9

func Byte() byte

Byte returns a random byte (alias for Uint8).

func Complex64

func Complex64() complex64

Complex64 returns a random complex64 with real and imaginary parts in [0, 1).

func Complex64Between added in v0.0.8

func Complex64Between(minReal, maxReal, minImag, maxImag float32) complex64

Complex64Between returns a random complex64 with real part in [minReal, maxReal] and imaginary part in [minImag, maxImag].

func Complex128

func Complex128() complex128

Complex128 returns a random complex128 with real and imaginary parts in [0, 1).

func Complex128Between added in v0.0.8

func Complex128Between(minReal, maxReal, minImag, maxImag float64) complex128

Complex128Between returns a random complex128 with real part in [minReal, maxReal] and imaginary part in [minImag, maxImag].

func ConjunctionPT added in v0.2.0

func ConjunctionPT() string

ConjunctionPT returns a real pt-PT conjunction, selected uniformly at random from the curated, exhaustive list of single-word coordinating and subordinating conjunctions (for example "e", "mas", "porém", "porque", "embora"). The result is a real, lowercase, correctly accented pt-PT word; conjunctional locutions are excluded and the length concept does not apply, so ConjunctionPT takes no length option.

ConjunctionPT draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines. For reproducible output, use a seeded Generator (New or NewSource) and its ConjunctionPT method.

func Date

func Date() time.Time

Date returns a random time.Time uniformly distributed across the full Gregorian calendar range (year 1–9999).

func DateBetween

func DateBetween(start, end time.Time) time.Time

DateBetween returns a random time.Time in [start, end]. Arguments are swapped if start is after end.

DateBetween operates at whole-second granularity: the bounds' sub-second components are ignored, and the returned time is in UTC with a zero sub-second component. As a special case, when start and end fall within the same second, start is returned unchanged, preserving its sub-second component and location.

func Float32

func Float32() float32

Float32 returns a random float32 in (0, math.MaxFloat32).

func Float32Between added in v0.0.8

func Float32Between(min, max float32) float32

Float32Between returns a random float32 in [min, max]. Arguments are swapped if min > max.

func Float64

func Float64() float64

Float64 returns a random float64 in (0, math.MaxFloat64).

func Float64Between added in v0.0.8

func Float64Between(min, max float64) float64

Float64Between returns a random float64 in [min, max]. Arguments are swapped if min > max.

func Int

func Int() int

Int returns a random int across the full [math.MinInt, math.MaxInt] range.

func Int8

func Int8() int8

Int8 returns a random int8 across the full [math.MinInt8, math.MaxInt8] range.

func Int8Between

func Int8Between(min, max int8) int8

Int8Between returns a random int8 in [min, max]. Arguments are swapped if min > max.

func Int16

func Int16() int16

Int16 returns a random int16 across the full [math.MinInt16, math.MaxInt16] range.

func Int16Between

func Int16Between(min, max int16) int16

Int16Between returns a random int16 in [min, max]. Arguments are swapped if min > max.

func Int32 added in v0.0.13

func Int32() int32

Int32 returns a random int32 across the full [math.MinInt32, math.MaxInt32] range.

func Int32Between added in v0.0.13

func Int32Between(min, max int32) int32

Int32Between returns a random int32 in [min, max]. Arguments are swapped if min > max.

func Int64

func Int64() int64

Int64 returns a random int64 across the full [math.MinInt64, math.MaxInt64] range.

func Int64Between

func Int64Between(min, max int64) int64

Int64Between returns a random int64 in [min, max]. Arguments are swapped if min > max.

func IntBetween

func IntBetween(min, max int) int

IntBetween returns a random int in [min, max]. Arguments are swapped if min > max.

func InterjectionPT added in v0.2.0

func InterjectionPT() string

InterjectionPT returns a real pt-PT interjection, selected uniformly at random from the curated, representative list of single-word interjections (for example "ah", "olá", "oxalá", "caramba", "psiu", "arre"). The result is a real, lowercase, correctly accented pt-PT word; interjectional locutions are excluded and the length concept does not apply, so InterjectionPT takes no length option.

InterjectionPT draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines. For reproducible output, use a seeded Generator (New or NewSource) and its InterjectionPT method.

func NounPT added in v0.2.0

func NounPT() string

NounPT returns a random European-Portuguese (pt-PT) pseudo-noun with a random gender, number and length. It is exact sugar for NounPTOf(AnyGender, AnyNumber, AnyLengthWord). The result is a lowercase, valid-UTF-8 word that follows pt-PT noun morphology and graphic accentuation; it is a plausible invented word, not guaranteed to be a real dictionary entry.

NounPT draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines. For reproducible output, use a seeded Generator (New or NewSource) and its NounPT method.

func NounPTOf added in v0.2.0

func NounPTOf(g Gender, n Number, l LengthTypeWords) string

NounPTOf returns a random pt-PT pseudo-noun inflected for gender g and number n, within length category l. Each option's Any zero value (AnyGender, AnyNumber, AnyLengthWord) selects a random valid value. A gender-inflecting ending realizes the requested gender directly; a gender-fixed or common-gender ending is chosen only when it is compatible with the request. When l cannot hold any noun of the chosen ending, l is normalized upward to the smallest category that can (length is never normalized downward). The result is always lowercase and valid UTF-8; the function never returns an error and never panics.

NounPTOf draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines.

Example

ExampleNounPTOf generates a pt-PT pseudo-noun inflected for a specific gender, number, and length category. Here the request is a feminine plural noun in the medium length category (5 to 8 characters).

package main

import (
	"fmt"

	"github.com/FlavioCFOliveira/gengo"
)

func main() {
	g := gengo.New(1)
	fmt.Println(g.NounPTOf(gengo.Feminine, gengo.Plural, gengo.MediumLengthWords))
}
Output:
gruistas

func NumeralPT added in v0.2.0

func NumeralPT() string

NumeralPT returns a real pt-PT numeral, selected uniformly at random from the curated list of single-word numerals across the four subtypes: cardinal, ordinal, multiplicative, and fractional (for example "três", "cem", "milhão", "primeiro", "décima", "vigésimo", "quíntuplo", "meio", "terço"). The result is a real, lowercase, correctly accented pt-PT word in European-Portuguese spelling (for example "catorze", "dezasseis", "bilião", never the Brazilian "quatorze", "dezesseis", "bilhão"); multi-word compound numbers (for example "vinte e um") are excluded and the length concept does not apply, so NumeralPT takes no length option.

NumeralPT draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines. For reproducible output, use a seeded Generator (New or NewSource) and its NumeralPT method.

func PrepositionPT added in v0.2.0

func PrepositionPT() string

PrepositionPT returns a real pt-PT preposition, selected uniformly at random from the curated, exhaustive list of essential (simple) prepositions (for example "a", "de", "para", "após", "sobre"). The result is a real, lowercase, correctly accented pt-PT word; prepositional locutions are excluded and the length concept does not apply, so PrepositionPT takes no length option.

PrepositionPT draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines. For reproducible output, use a seeded Generator (New or NewSource) and its PrepositionPT method.

Example

ExamplePrepositionPT selects a real pt-PT preposition. Closed-class selectors return genuine, curated words rather than generated pseudo-words.

package main

import (
	"fmt"

	"github.com/FlavioCFOliveira/gengo"
)

func main() {
	g := gengo.New(5)
	fmt.Println(g.PrepositionPT())
}
Output:
perante

func PronounPT added in v0.2.0

func PronounPT() string

PronounPT returns a real pt-PT pronoun, selected uniformly at random from the curated, exhaustive list that spans every subtype: personal (subject, atonic oblique, and tonic oblique, including the archaic-but-real "vós" forms such as "vós", "convosco", and "vosso"), possessive, demonstrative, indefinite, relative, and interrogative (for example "eu", "lhe", "consigo", "minhas", "aquilo", "nenhuma", "cujo", "quem"). The result is a real, lowercase, correctly accented pt-PT word; the length concept does not apply to closed classes, so PronounPT takes no length option.

PronounPT draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines. For reproducible output, use a seeded Generator (New or NewSource) and its PronounPT method.

func String

func String(length uint32, sourceChars string) string

String generates a length-byte string by sampling bytes from sourceChars.

It is byte-oriented: length counts bytes (not runes), characters are picked by byte index, and sourceChars is expected to hold only single-byte (ASCII) characters — every predefined character set in this package qualifies. Passing a multibyte charset (emoji, accented letters, CJK, and so on) samples individual UTF-8 bytes and therefore yields invalid UTF-8, so use an ASCII charset instead. length is capped at MaxStringLength bytes.

Example
HexColor := String(8, "0123456789ABCDEF")
fmt.Println(HexColor)

func StringAllChars

func StringAllChars(length uint32) string

StringAllChars returns a string with a given length containing all the predefined alphabetic, alphanumeric and symbols characters.

func StringAlphabetic

func StringAlphabetic(length uint32) string

StringAlphabetic returns a string with a given length containing only alphabetic characters.

func StringAlphabeticLowercase

func StringAlphabeticLowercase(length uint32) string

StringAlphabeticLowercase returns a string with a given length containing only alphabetic characters in lower case only.

func StringAlphabeticUppercase

func StringAlphabeticUppercase(length uint32) string

StringAlphabeticUppercase returns a string with a given length containing only alphabetic characters in upper case only.

func StringAlphanumeric

func StringAlphanumeric(length uint32) string

StringAlphanumeric returns a string with a given length containing only alphanumeric characters.

func StringBetween added in v0.0.10

func StringBetween(min, max uint32, sourceChars string) string

StringBetween generates a string with a variable length using only characters of a given source.

func StringHexadecimal

func StringHexadecimal(length uint32) string

StringHexadecimal returns a string with a given length containing only hexadecimal characters.

func StringNumeric

func StringNumeric(length uint32) string

StringNumeric returns a string with a given length containing only numeric characters.

func StringSymbols

func StringSymbols(length uint32) string

StringSymbols returns a string with a given length containing only symbols characters.

func Uint8 added in v0.1.0

func Uint8() uint8

Uint8 returns a random uint8 across the full [0, math.MaxUint8] range.

func Uint8Between added in v0.1.0

func Uint8Between(min, max uint8) uint8

Uint8Between returns a random uint8 in [min, max]. Arguments are swapped if min > max.

func Uint16 added in v0.1.0

func Uint16() uint16

Uint16 returns a random uint16 across the full [0, math.MaxUint16] range.

func Uint16Between added in v0.1.0

func Uint16Between(min, max uint16) uint16

Uint16Between returns a random uint16 in [min, max]. Arguments are swapped if min > max.

func Uint32 added in v0.1.0

func Uint32() uint32

Uint32 returns a random uint32 across the full [0, math.MaxUint32] range.

func Uint32Between added in v0.1.0

func Uint32Between(min, max uint32) uint32

Uint32Between returns a random uint32 in [min, max]. Arguments are swapped if min > max.

func Uint64 added in v0.1.0

func Uint64() uint64

Uint64 returns a random uint64 across the full [0, math.MaxUint64] range.

func Uint64Between added in v0.1.0

func Uint64Between(min, max uint64) uint64

Uint64Between returns a random uint64 in [min, max]. Arguments are swapped if min > max.

func UnixDate added in v0.0.13

func UnixDate() time.Time

UnixDate returns a random time.Time uniformly distributed within the Unix epoch range (1970–2038).

func VerbPT added in v0.2.0

func VerbPT() string

VerbPT returns a random European-Portuguese (pt-PT) pseudo-verb form in a random paradigm slot: a random mood, tense, person, number and length. It is exact sugar for VerbPTOf(AnyMood, AnyTense, AnyPerson, AnyNumber, AnyLengthWord). The result is a lowercase, valid-UTF-8 word that follows the regular pt-PT verb conjugation and graphic accentuation; it is a plausible invented word, not guaranteed to be a real dictionary entry.

VerbPT draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines. For reproducible output, use a seeded Generator (New or NewSource) and its VerbPT method.

func VerbPTOf added in v0.2.0

func VerbPTOf(m Mood, t Tense, p Person, n Number, l LengthTypeWords) string

VerbPTOf returns a random pt-PT pseudo-verb produced in the paradigm slot addressed by mood m, tense t, person p and number n, within length category l. Each option's Any zero value (AnyMood, AnyTense, AnyPerson, AnyNumber, AnyLengthWord) selects a random valid value for the resolved mood.

The mood governs which of the other options apply. The finite indicative and subjunctive use the tense, person and number; the imperative uses the person and number (it has no tense selection); the infinitive uses the person and number (to choose between the impersonal and the inflected personal infinitive); the gerund and the participle are invariable (person, number and tense are ignored).

Grammatically impossible combinations never error or panic; each normalizes to the nearest valid form, per the deterministic matrix of specification/wordspt-open-classes.md: a second person plural request becomes third person plural (N1); a first person singular imperative becomes first person plural (N2); a subjunctive Preterite becomes Imperfect and a subjunctive Conditional becomes Future (N3); a tense on a non-finite or imperative mood is ignored (N3); and an unviable length category is normalized upward to the smallest category that can hold the resolved slot (N5), never downward. The result is always lowercase and valid UTF-8.

VerbPTOf draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines.

Example

ExampleVerbPTOf generates a pt-PT pseudo-verb in a specific paradigm slot: the present indicative, first person singular.

package main

import (
	"fmt"

	"github.com/FlavioCFOliveira/gengo"
)

func main() {
	g := gengo.New(3)
	fmt.Println(g.VerbPTOf(gengo.Indicative, gengo.Present, gengo.First, gengo.Singular, gengo.AnyLengthWord))
}
Output:
onalgro

func Word

func Word() string

Word returns a random lowercase alphabetic word between 2 and 30 characters.

func WordByLengthType

func WordByLengthType(l LengthTypeWords) (word string)

WordByLengthType returns a random lowercase alphabetic word of the given length category.

func WordPT added in v0.2.0

func WordPT() string

WordPT returns a random European-Portuguese (pt-PT) word of a random class, following the natural class distribution described in this package. It is exact sugar for WordPTByLengthType(AnyLengthWord). The result is a lowercase, valid-UTF-8 pt-PT word: a generated pseudo-word for the open classes (noun, adjective, verb, adverb) or a real curated word for the closed classes (article, pronoun, numeral, preposition, conjunction, interjection).

WordPT draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines. For reproducible output, use a seeded Generator (New or NewSource) and its WordPT method.

func WordPTByLengthType added in v0.2.0

func WordPTByLengthType(l LengthTypeWords) string

WordPTByLengthType returns a random pt-PT word of a random class, as WordPT, with the length category l applied to the open classes. A concrete category (SmallLengthWord, MediumLengthWords or BigLengthWords) constrains a generated open-class word to that character window, normalizing upward when the category cannot hold the chosen class (length is never normalized downward). AnyLengthWord (the zero value) selects the natural length distribution. The closed classes ignore l entirely, because their output is a fixed real word. The result is always lowercase and valid UTF-8; the function never returns an error and never panics.

WordPTByLengthType draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines.

func Words

func Words(length int) (result []string)

Words returns a slice of length random words with a natural distribution across length categories. Returns an empty slice when length <= 0.

func WordsPT added in v0.2.0

func WordsPT(n int) []string

WordsPT returns a slice of n random pt-PT words following the natural class distribution, mirroring the semantics of Words. It returns a non-nil, empty slice when n is less than or equal to zero, and a slice of exactly n words otherwise. Each word is drawn independently, exactly as WordPT draws one.

WordsPT draws from the global, automatically seeded math/rand/v2 source and is safe for concurrent use by multiple goroutines. For reproducible output, use a seeded Generator (New or NewSource) and its WordsPT method.

Example

ExampleWordsPT generates a slice of random pt-PT words following the natural distribution across word classes. Open-class words are generated pseudo-words, while closed-class words (such as the numeral "quatro" below) are real words.

package main

import (
	"fmt"

	"github.com/FlavioCFOliveira/gengo"
)

func main() {
	g := gengo.New(6)
	fmt.Println(g.WordsPT(5))
}
Output:
[quatro escas sesmando murnalmente seblares]

Types

type Degree added in v0.2.0

type Degree uint8

Degree is the degree option of a generated adjective. Its zero value, AnyDegree, means "choose a valid degree at random". Only the positive and the synthetic absolute superlative (-íssimo) are supported; the comparative and the analytic superlatives are multi-word forms and are out of scope.

const (
	// AnyDegree is the zero value of [Degree] and selects a random valid degree.
	AnyDegree Degree = iota
	// Positive selects the base (positive) degree.
	Positive
	// Superlative selects the synthetic absolute superlative (-íssimo).
	Superlative
)

type Gender added in v0.2.0

type Gender uint8

Gender is the grammatical gender option of a generated nominal pt-PT word. Its zero value, AnyGender, means "choose a valid gender at random".

const (
	// AnyGender is the zero value of [Gender] and selects a random valid gender.
	AnyGender Gender = iota
	// Masculine selects the masculine form of a gender-inflecting word.
	Masculine
	// Feminine selects the feminine form of a gender-inflecting word.
	Feminine
)

type Generator added in v0.1.0

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

Generator produces random values from an explicit, seeded source, enabling reproducible output: two generators created with the same seed yield the same sequence of values. Its methods mirror the package-level functions exactly, drawing from the generator's own source instead of the global one.

A Generator is NOT safe for concurrent use by multiple goroutines (it wraps a math/rand/v2 *Rand). Use one Generator per goroutine, or use the package-level functions (which are safe for concurrent use) when reproducibility is not required.

Example

ExampleGenerator shows that two generators created with the same seed produce the same sequence of words, which is what makes seeded output reproducible.

package main

import (
	"fmt"

	"github.com/FlavioCFOliveira/gengo"
)

func main() {
	a := gengo.New(7)
	b := gengo.New(7)
	fmt.Println(a.WordsPT(3))
	fmt.Println(b.WordsPT(3))
}
Output:
[a sedoraríamos teichãospores]
[a sedoraríamos teichãospores]

func New added in v0.1.0

func New(seed uint64) *Generator

New returns a Generator seeded with the given value. The same seed always produces the same sequence of values, which is useful for reproducing a specific run (for example, a failing test case).

func NewSource added in v0.1.0

func NewSource(src rand.Source) *Generator

NewSource returns a Generator that draws from the given source, allowing any math/rand/v2 Source (for example rand.NewPCG or rand.NewChaCha8) to be used. The source must not be nil.

func (*Generator) AdjectivePT added in v0.2.0

func (g *Generator) AdjectivePT() string

AdjectivePT is the seeded-generator equivalent of AdjectivePT. A Generator created with the same seed produces the same sequence of adjectives.

func (*Generator) AdjectivePTOf added in v0.2.0

func (g *Generator) AdjectivePTOf(gender Gender, n Number, d Degree, l LengthTypeWords) string

AdjectivePTOf is the seeded-generator equivalent of AdjectivePTOf. A Generator created with the same seed produces the same sequence of adjectives for the same arguments.

func (*Generator) AdverbPT added in v0.2.0

func (g *Generator) AdverbPT() string

AdverbPT is the seeded-generator equivalent of AdverbPT. A Generator created with the same seed produces the same sequence of adverbs.

func (*Generator) AdverbPTByLengthType added in v0.2.0

func (g *Generator) AdverbPTByLengthType(l LengthTypeWords) string

AdverbPTByLengthType is the seeded-generator equivalent of AdverbPTByLengthType. A Generator created with the same seed produces the same sequence of adverbs for the same length category.

func (*Generator) ArticlePT added in v0.2.0

func (g *Generator) ArticlePT() string

ArticlePT is the seeded-generator equivalent of ArticlePT. A Generator created with the same seed produces the same sequence of articles.

func (*Generator) Bool added in v0.1.0

func (g *Generator) Bool() bool

Bool is the seeded-generator equivalent of Bool.

func (*Generator) Byte added in v0.1.0

func (g *Generator) Byte() byte

Byte is the seeded-generator equivalent of Byte.

func (*Generator) Complex64 added in v0.1.0

func (g *Generator) Complex64() complex64

Complex64 is the seeded-generator equivalent of Complex64.

func (*Generator) Complex64Between added in v0.1.0

func (g *Generator) Complex64Between(minReal, maxReal, minImag, maxImag float32) complex64

Complex64Between is the seeded-generator equivalent of Complex64Between.

func (*Generator) Complex128 added in v0.1.0

func (g *Generator) Complex128() complex128

Complex128 is the seeded-generator equivalent of Complex128.

func (*Generator) Complex128Between added in v0.1.0

func (g *Generator) Complex128Between(minReal, maxReal, minImag, maxImag float64) complex128

Complex128Between is the seeded-generator equivalent of Complex128Between.

func (*Generator) ConjunctionPT added in v0.2.0

func (g *Generator) ConjunctionPT() string

ConjunctionPT is the seeded-generator equivalent of ConjunctionPT. A Generator created with the same seed produces the same sequence of conjunctions.

func (*Generator) Date added in v0.1.0

func (g *Generator) Date() time.Time

Date is the seeded-generator equivalent of Date.

func (*Generator) DateBetween added in v0.1.0

func (g *Generator) DateBetween(start, end time.Time) time.Time

DateBetween is the seeded-generator equivalent of DateBetween.

func (*Generator) Float32 added in v0.1.0

func (g *Generator) Float32() float32

Float32 is the seeded-generator equivalent of Float32.

func (*Generator) Float32Between added in v0.1.0

func (g *Generator) Float32Between(min, max float32) float32

Float32Between is the seeded-generator equivalent of Float32Between.

func (*Generator) Float64 added in v0.1.0

func (g *Generator) Float64() float64

Float64 is the seeded-generator equivalent of Float64.

func (*Generator) Float64Between added in v0.1.0

func (g *Generator) Float64Between(min, max float64) float64

Float64Between is the seeded-generator equivalent of Float64Between.

func (*Generator) Int added in v0.1.0

func (g *Generator) Int() int

Int is the seeded-generator equivalent of Int.

func (*Generator) Int8 added in v0.1.0

func (g *Generator) Int8() int8

Int8 is the seeded-generator equivalent of Int8.

func (*Generator) Int8Between added in v0.1.0

func (g *Generator) Int8Between(min, max int8) int8

Int8Between is the seeded-generator equivalent of Int8Between.

func (*Generator) Int16 added in v0.1.0

func (g *Generator) Int16() int16

Int16 is the seeded-generator equivalent of Int16.

func (*Generator) Int16Between added in v0.1.0

func (g *Generator) Int16Between(min, max int16) int16

Int16Between is the seeded-generator equivalent of Int16Between.

func (*Generator) Int32 added in v0.1.0

func (g *Generator) Int32() int32

Int32 is the seeded-generator equivalent of Int32.

func (*Generator) Int32Between added in v0.1.0

func (g *Generator) Int32Between(min, max int32) int32

Int32Between is the seeded-generator equivalent of Int32Between.

func (*Generator) Int64 added in v0.1.0

func (g *Generator) Int64() int64

Int64 is the seeded-generator equivalent of Int64.

func (*Generator) Int64Between added in v0.1.0

func (g *Generator) Int64Between(min, max int64) int64

Int64Between is the seeded-generator equivalent of Int64Between.

func (*Generator) IntBetween added in v0.1.0

func (g *Generator) IntBetween(min, max int) int

IntBetween is the seeded-generator equivalent of IntBetween.

func (*Generator) InterjectionPT added in v0.2.0

func (g *Generator) InterjectionPT() string

InterjectionPT is the seeded-generator equivalent of InterjectionPT. A Generator created with the same seed produces the same sequence of interjections.

func (*Generator) NounPT added in v0.2.0

func (g *Generator) NounPT() string

NounPT is the seeded-generator equivalent of NounPT. A Generator created with the same seed produces the same sequence of nouns.

func (*Generator) NounPTOf added in v0.2.0

func (g *Generator) NounPTOf(gender Gender, n Number, l LengthTypeWords) string

NounPTOf is the seeded-generator equivalent of NounPTOf. A Generator created with the same seed produces the same sequence of nouns for the same arguments.

func (*Generator) NumeralPT added in v0.2.0

func (g *Generator) NumeralPT() string

NumeralPT is the seeded-generator equivalent of NumeralPT. A Generator created with the same seed produces the same sequence of numerals.

func (*Generator) PrepositionPT added in v0.2.0

func (g *Generator) PrepositionPT() string

PrepositionPT is the seeded-generator equivalent of PrepositionPT. A Generator created with the same seed produces the same sequence of prepositions.

func (*Generator) PronounPT added in v0.2.0

func (g *Generator) PronounPT() string

PronounPT is the seeded-generator equivalent of PronounPT. A Generator created with the same seed produces the same sequence of pronouns.

func (*Generator) String added in v0.1.0

func (g *Generator) String(length uint32, sourceChars string) string

String is the seeded-generator equivalent of String.

func (*Generator) StringAllChars added in v0.1.0

func (g *Generator) StringAllChars(length uint32) string

StringAllChars is the seeded-generator equivalent of StringAllChars.

func (*Generator) StringAlphabetic added in v0.1.0

func (g *Generator) StringAlphabetic(length uint32) string

StringAlphabetic is the seeded-generator equivalent of StringAlphabetic.

func (*Generator) StringAlphabeticLowercase added in v0.1.0

func (g *Generator) StringAlphabeticLowercase(length uint32) string

StringAlphabeticLowercase is the seeded-generator equivalent of StringAlphabeticLowercase.

func (*Generator) StringAlphabeticUppercase added in v0.1.0

func (g *Generator) StringAlphabeticUppercase(length uint32) string

StringAlphabeticUppercase is the seeded-generator equivalent of StringAlphabeticUppercase.

func (*Generator) StringAlphanumeric added in v0.1.0

func (g *Generator) StringAlphanumeric(length uint32) string

StringAlphanumeric is the seeded-generator equivalent of StringAlphanumeric.

func (*Generator) StringBetween added in v0.1.0

func (g *Generator) StringBetween(min, max uint32, sourceChars string) string

StringBetween is the seeded-generator equivalent of StringBetween.

func (*Generator) StringHexadecimal added in v0.1.0

func (g *Generator) StringHexadecimal(length uint32) string

StringHexadecimal is the seeded-generator equivalent of StringHexadecimal.

func (*Generator) StringNumeric added in v0.1.0

func (g *Generator) StringNumeric(length uint32) string

StringNumeric is the seeded-generator equivalent of StringNumeric.

func (*Generator) StringSymbols added in v0.1.0

func (g *Generator) StringSymbols(length uint32) string

StringSymbols is the seeded-generator equivalent of StringSymbols.

func (*Generator) Uint8 added in v0.1.0

func (g *Generator) Uint8() uint8

Uint8 is the seeded-generator equivalent of Uint8.

func (*Generator) Uint8Between added in v0.1.0

func (g *Generator) Uint8Between(min, max uint8) uint8

Uint8Between is the seeded-generator equivalent of Uint8Between.

func (*Generator) Uint16 added in v0.1.0

func (g *Generator) Uint16() uint16

Uint16 is the seeded-generator equivalent of Uint16.

func (*Generator) Uint16Between added in v0.1.0

func (g *Generator) Uint16Between(min, max uint16) uint16

Uint16Between is the seeded-generator equivalent of Uint16Between.

func (*Generator) Uint32 added in v0.1.0

func (g *Generator) Uint32() uint32

Uint32 is the seeded-generator equivalent of Uint32.

func (*Generator) Uint32Between added in v0.1.0

func (g *Generator) Uint32Between(min, max uint32) uint32

Uint32Between is the seeded-generator equivalent of Uint32Between.

func (*Generator) Uint64 added in v0.1.0

func (g *Generator) Uint64() uint64

Uint64 is the seeded-generator equivalent of Uint64.

func (*Generator) Uint64Between added in v0.1.0

func (g *Generator) Uint64Between(min, max uint64) uint64

Uint64Between is the seeded-generator equivalent of Uint64Between.

func (*Generator) UnixDate added in v0.1.0

func (g *Generator) UnixDate() time.Time

UnixDate is the seeded-generator equivalent of UnixDate.

func (*Generator) VerbPT added in v0.2.0

func (g *Generator) VerbPT() string

VerbPT is the seeded-generator equivalent of VerbPT. A Generator created with the same seed produces the same sequence of verb forms.

func (*Generator) VerbPTOf added in v0.2.0

func (g *Generator) VerbPTOf(m Mood, t Tense, p Person, n Number, l LengthTypeWords) string

VerbPTOf is the seeded-generator equivalent of VerbPTOf. A Generator created with the same seed produces the same sequence of verb forms for the same arguments.

func (*Generator) Word added in v0.1.0

func (g *Generator) Word() string

Word is the seeded-generator equivalent of Word.

func (*Generator) WordByLengthType added in v0.1.0

func (g *Generator) WordByLengthType(l LengthTypeWords) (word string)

WordByLengthType is the seeded-generator equivalent of WordByLengthType.

func (*Generator) WordPT added in v0.2.0

func (g *Generator) WordPT() string

WordPT is the seeded-generator equivalent of WordPT. A Generator created with the same seed produces the same sequence of words.

func (*Generator) WordPTByLengthType added in v0.2.0

func (g *Generator) WordPTByLengthType(l LengthTypeWords) string

WordPTByLengthType is the seeded-generator equivalent of WordPTByLengthType. A Generator created with the same seed produces the same sequence of words for the same length category.

func (*Generator) Words added in v0.1.0

func (g *Generator) Words(length int) []string

Words is the seeded-generator equivalent of Words.

func (*Generator) WordsPT added in v0.2.0

func (g *Generator) WordsPT(n int) []string

WordsPT is the seeded-generator equivalent of WordsPT. A Generator created with the same seed produces the same sequence of word slices.

type LengthTypeWords

type LengthTypeWords uint8

LengthTypeWords classifies a word by its character length category.

const AnyLengthWord LengthTypeWords = 0

AnyLengthWord is the zero value of LengthTypeWords and selects the full length range (any category). It is the length counterpart of the Any zero value used by the WordsPT flexion enums (Gender, Number, Degree).

const BigLengthWords LengthTypeWords = 3

BigLengthWords represents big length words, 9 to 30 chars.

const MediumLengthWords LengthTypeWords = 2

MediumLengthWords represents medium length words, 5 to 8 chars.

const SmallLengthWord LengthTypeWords = 1

SmallLengthWord represents small length words, 1 to 4 chars.

type Mood added in v0.2.0

type Mood uint8

Mood is the grammatical mood option of a generated pt-PT verb. Its zero value, AnyMood, means "choose a valid mood at random". The finite moods (Indicative, Subjunctive, ImperativeAffirmative, ImperativeNegative) inflect for person and number; the indicative and subjunctive additionally inflect for Tense. The non-finite moods (Infinitive, Gerund, Participle) take no tense; of these, only the personal infinitive inflects for person and number.

const (
	// AnyMood is the zero value of [Mood] and selects a random valid mood.
	AnyMood Mood = iota
	// Indicative selects the indicative mood (finite).
	Indicative
	// Subjunctive selects the subjunctive (conjuntivo) mood (finite).
	Subjunctive
	// ImperativeAffirmative selects the affirmative imperative mood (finite).
	ImperativeAffirmative
	// ImperativeNegative selects the negative imperative mood. In pt-PT the negated
	// command is periphrastic ("não" + present subjunctive); WordsPT, a single-word
	// generator, produces only the verb form, without the negating particle.
	ImperativeNegative
	// Infinitive selects the infinitive mood: the impersonal infinitive (falar) or,
	// for a concrete person and number, the inflected personal infinitive.
	Infinitive
	// Gerund selects the gerund (gerúndio): the invariable -ndo form (falando).
	Gerund
	// Participle selects the past participle: the invariable masculine singular form
	// (falado, comido, partido).
	Participle
)

type Number added in v0.2.0

type Number uint8

Number is the grammatical number option of a generated nominal pt-PT word. Its zero value, AnyNumber, means "choose a valid number at random".

const (
	// AnyNumber is the zero value of [Number] and selects a random valid number.
	AnyNumber Number = iota
	// Singular selects the singular form.
	Singular
	// Plural selects the plural form, built by the Portuguese plural engine.
	Plural
)

type Person added in v0.2.0

type Person uint8

Person is the grammatical person option of a generated pt-PT verb. Its zero value, AnyPerson, means "choose a valid person at random". WordsPT follows current pt-PT usage without the archaic second person plural ("vós"): a second person plural request normalizes to the third person plural (see the package documentation, Normalization rule N1).

const (
	// AnyPerson is the zero value of [Person] and selects a random valid person.
	AnyPerson Person = iota
	// First selects the first person (eu / nós).
	First
	// Second selects the second person (tu).
	Second
	// Third selects the third person (singular ele/ela, plural elas/vocês).
	Third
)

type Tense added in v0.2.0

type Tense uint8

Tense is the grammatical tense option of a generated pt-PT verb. Its zero value, AnyTense, means "choose a valid tense at random for the resolved mood". Tense applies only to the finite moods; on the non-finite and imperative moods a requested tense is ignored.

const (
	// AnyTense is the zero value of [Tense] and selects a random valid tense.
	AnyTense Tense = iota
	// Present selects the present tense.
	Present
	// Imperfect selects the imperfect past tense.
	Imperfect
	// Preterite selects the preterite (perfect past) tense.
	Preterite
	// Future selects the future tense.
	Future
	// Conditional selects the conditional tense.
	Conditional
)

Jump to

Keyboard shortcuts

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