Skip to content

a lightweight package that simplifies the process of creating dummy or fake struct for many purposes like testing in Go

License

Notifications You must be signed in to change notification settings

ErfanMomeniii/factory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go version license version

factory

factory is a lightweight package for generating fake data that helps generate realistic but fictional data for various purposes, such as testing, prototyping, or populating databases with sample data.

Documentation

Install

go get github.com/erfanmomeniii/factory

Next, include it in your application:

import "github.com/erfanmomeniii/factory"

Quick Start

The following examples illustrates how to use this package:

package main

import (
	"fmt"

	"github.com/erfanmomeniii/factory"
)

type Name struct {
	FirstName string
	LastName  string
}
type Info struct {
	Name  Name
	Phone int
}

func main() {
	f := factory.NewFactory()

	instances := f.Model(Info{}).
		Generate(2)

	for _, i := range instances {
		instance := i.(Info)
		fmt.Println("Name : ", instance.Name.FirstName+" "+instance.Name.LastName, " | Phone : ", instance.Phone)
	}
}

Contributing

Pull requests are welcome. For changes, please open an issue first to discuss what you would like to change. Please make sure to update tests as appropriate.

About

a lightweight package that simplifies the process of creating dummy or fake struct for many purposes like testing in Go

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages