Help us shape the future of Go! Take the 2026 Go Developer Survey

seed

package
v1.11.9 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package seed provides development and test data generation. Seed plans are not a production migration mechanism and their generated data must not contain real credentials or personal information.

Index

Constants

This section is empty.

Variables

View Source
var DefaultFaker = NewFaker()

DefaultFaker is the process-wide development data generator.

Functions

func Run

func Run(ctx context.Context, client *dbcore.Client, plans ...Plan) error

Run executes batch seeding plans against a dbcore.Client instance.

Types

type Faker

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

Faker generates realistic fake data for testing and database seeding without external dependencies.

func NewFaker

func NewFaker() *Faker

NewFaker creates a new Faker instance.

func (*Faker) Address

func (f *Faker) Address() string

Address generates a random street address (e.g. "742 Evergreen Terrace, San Francisco, CA").

func (*Faker) Bool

func (f *Faker) Bool() bool

Bool returns a random boolean value.

func (*Faker) Company

func (f *Faker) Company() string

Company generates a random company name.

func (*Faker) Email

func (f *Faker) Email() string

Email generates a random email address (e.g. "alex.smith42@gmail.com").

func (*Faker) FloatRange

func (f *Faker) FloatRange(min, max float64) float64

FloatRange returns a random float64 between min and max.

func (*Faker) FutureDate

func (f *Faker) FutureDate() time.Time

FutureDate returns a time.Time in the future up to 365 days ahead.

func (*Faker) IntRange

func (f *Faker) IntRange(min, max int) int

IntRange returns a random integer between min and max inclusive.

func (*Faker) Name

func (f *Faker) Name() string

Name generates a random full name (e.g. "Alex Smith").

func (*Faker) Paragraph

func (f *Faker) Paragraph() string

Paragraph generates a paragraph of text sentences.

func (*Faker) Password

func (f *Faker) Password() string

Password generates a random secure password string.

func (*Faker) PastDate

func (f *Faker) PastDate() time.Time

PastDate returns a time.Time in the past up to 365 days ago.

func (*Faker) Phone

func (f *Faker) Phone() string

Phone generates a random US-formatted phone number (e.g. "+1-555-019-2834").

func (*Faker) Select

func (f *Faker) Select(options ...string) string

Select picks a random option from the provided options slice.

func (*Faker) Sentence

func (f *Faker) Sentence() string

Sentence generates a random dummy text sentence.

func (*Faker) UUID

func (f *Faker) UUID() string

UUID generates a random UUID v4 string.

type Plan

type Plan struct {
	Table         string
	Count         int
	Factory       func(f *Faker) map[string]any
	TruncateFirst bool
}

Plan defines a declarative database seeding task.

Jump to

Keyboard shortcuts

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