lorem

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

README

go-lorem

Seeded or nonseeded lorem ipsum generator for Go

Forked from https://github.com/drhodes/golorem

This fork adds the ability to generated seeded lorem ipsum text and uses the upgraded random/v2 package for random number generation.

Example

package main

import (
    "fmt"
    "github.com/mcnull/go-lorem"
)

func main() {
    // Generate a random paragraph
    fmt.Println(lorem.Paragraph(5, 10))

    // Generate a random sentence
    fmt.Println(lorem.Sentence(5, 10))

    // Generate a random word
    fmt.Println(lorem.Word(5, 10))

    // Generate a random email
    fmt.Println(lorem.Email())

    // Generate a random URL
    fmt.Println(lorem.URL())

    // Generate a random host
    fmt.Println(lorem.Host())

    // Generate a random UUID
    fmt.Println(lorem.UUID())
}

Seeded

A seeded lorem generator is also available. This allows you to generate the same random text each time you run your program. This is useful for testing.

package main

import (
    "fmt"
    "github.com/mcnull/go-lorem"
)

func main() {
    // Generate a seeded lorem ipsum generator
    l := lorem.NewSeed(1,2)

    // Generate a random paragraph
    fmt.Println(l.Paragraph(5, 10))

    // Same function as above can be called on the instance.
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Email

func Email() string

Email

func GenerateUniqueRandomInts added in v1.0.3

func GenerateUniqueRandomInts(r *rand.Rand, max, n int) []int

func Host

func Host() string

Host

func Paragraph

func Paragraph(min, max int) string

func Pick added in v1.0.3

func Pick[T any](r *rand.Rand, arr []T) T

func PickMultiple added in v1.0.3

func PickMultiple[T any](r *rand.Rand, arr []T, n int) []T

func PickUnique added in v1.0.3

func PickUnique[T any](r *rand.Rand, arr []T, n int) []T

func RandomUUID

func RandomUUID(rnd *rand.Rand) uuid.UUID

func Sentence

func Sentence(min, max int) string

Generate a sentence with a specified range of words.

func UUID

func UUID() string

UUID

func Url

func Url() string

Generate a random URL

func Word

func Word(min, max int) string

Generate a word in a specfied range of letters.

Types

type Lorem

type Lorem struct {
	Randomizer *rand.Rand
}

func New

func New() *Lorem

func NewSeeded

func NewSeeded(seed1 uint64, seed2 uint64) *Lorem

func (*Lorem) Email

func (l *Lorem) Email() string

Email

func (*Lorem) Host

func (l *Lorem) Host() string

Host

func (*Lorem) Paragraph

func (l *Lorem) Paragraph(min, max int) string

func (*Lorem) PickInt added in v1.0.3

func (l *Lorem) PickInt(arr []int) int

func (*Lorem) PickInts added in v1.0.3

func (l *Lorem) PickInts(arr []int, n int) []int

func (*Lorem) PickString added in v1.0.3

func (l *Lorem) PickString(arr []string) string

func (*Lorem) PickStrings added in v1.0.3

func (l *Lorem) PickStrings(arr []string, n int) []string

func (*Lorem) PickUniqueInts added in v1.0.3

func (l *Lorem) PickUniqueInts(arr []int, n int) []int

func (*Lorem) PickUniqueStrings added in v1.0.3

func (l *Lorem) PickUniqueStrings(arr []string, n int) []string

func (*Lorem) Sentence

func (l *Lorem) Sentence(min, max int) string

Generate a sentence with a specified range of words.

func (*Lorem) UUID

func (l *Lorem) UUID() string

func (*Lorem) Url

func (l *Lorem) Url() string

Generate a random URL

func (*Lorem) Word

func (l *Lorem) Word(min, max int) string

Generate a word in a specfied range of letters.

func (*Lorem) Words added in v1.0.4

func (l *Lorem) Words(n, min, max int) []string

Jump to

Keyboard shortcuts

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