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

fakedata

command module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2017 License: MIT Imports: 7 Imported by: 0

README

fakedata

fakedata is a small command line utility that generates random data.

For questions join the #fakedata channel in the Gophers Slack.

Table Of Contents

Overview

Here is a list of examples to get a feeling of how fakedata works

$ fakedata email country
cemshid@example.com Afghanistan
LucasPerdidao@example.me Turkey
arthurholcombe1@test.us Saint Helena
iamgarth@example.us Montenegro
joelcipriano@test.name Croatia
keryilmaz@test.name Vietnam
plbabin@test.org Lithuania
bermonpainter@test.us Haiti
opnsrce@example.name Malaysia
ankitind@test.info Virgin Islands, British

Limit the number of rows:

$ fakedata --limit 5 country.code
SH
CF
GQ
PE
FO

Choose a different output format:

$ fakedata --format=csv product.category product.name
Shoes,Rankfix
Automotive,Namis
Movies,Matquadfax
Tools,Damlight
Computers,Silverlux
Industrial,Matquadfax
Home,Sil-Home
Health,Toughwarm
Shoes,Freetop
Tools,Domnix

Generators

fakedata provides a number of generators. You can see the full list running the following command:

$ fakedata --generators
color             one word color
country           Full country name
country.code      2-digit country code
date              date
domain            domain
domain.tld        example|test
# ...
# It's a long list :)

Some generators allow you to pass in a range to constraint the output to a subset of values:

$ fakedata int,1..100 # will generate only integers between 1 and 100
$ fakedata int,50.. # specifying only min number works too
$ fakedata int,50 # also works

The enum generator allows you to specify a set of values. It comes handy when you need random data from a small subset of values:

$ fakedata --limit 5 enum
foo
baz
foo
foo
baz
$ fakedata --limit 5 enum,bug..feature..question..duplicate
question
duplicate
duplicate
bug
feature

When passing a single value enum can be used to repeat a value in every line:

$ fakedata --limit 5 enum,one..two enum,repeat
two repeat
one repeat
two repeat
one repeat
one repeat

The file generator can be use to read custom values from a file:

$ printf "one\ntwo\nthree" > values.txt
$ fakedata -l5 file,values.txt
three
two
two
one
two

Formatters

SQL formatter

fakedata can generate insert statements. By default, it uses the name of the generators as column names:

$ fakedata --format=sql --limit 1 email domain
INSERT INTO TABLE (email,domain) values ('yigitpinar@example.org','example.me');

You can specify the name of the column using a field with the following format column_name=generator:

$ fakedata --format=sql --limit 1 login=email referral=domain
INSERT INTO TABLE (login,referral) values ('calebogden@example.com','test.me');
fakedata --format=sql --limit=1 --table=users login=email referral=domain
INSERT INTO users (login,referral) VALUES ('mikema@example.com' 'test.us');

How to install

Homebrew

fakedata can be installed through Homebrew:

$ brew install lucapette/tap/fakedata

Standalone

fakedata can be installed as an executable. Download the latest compiled binaries and put it anywhere in your executable path.

Source

Please refer to our contributing guidelines to build and install fakedata from the source.

How to contribute

We love every form of contribution! Good entry points to the project are:

If you're still not sure where to start, please open a new issue and we'll gladly help you get started.

Code of Conduct

You are expected to follow our code of conduct when interacting with the project via issues, pull requests or in any other form. Many thanks to the awesome contributor covenant initiative!

License

MIT License Copyright (c) [2017] Luca Pette

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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