- Notifications
You must be signed in to change notification settings - Fork5
A Go library to generate random data for testing and/or performance evaluation
License
cilium/fake
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Fake is a Go library and CLI to generate random data such as names, adjectives,IP addresses and so on.
This repository contains three Go modules:
github.com/cilium/fake
: a library to generate generic random data whichcan be useful to any project (e.g.fake.Adjective()
,fake.IP()
, ...).github.com/cilium/fake/flow
: a library to generate randomHubblenetwork flows and flow related data. This library is only relevant to projectsdirectly related toCilium and/orHubble.github.com/cilium/fake/cmd
: a CLI to generate random data.
As opposed to most fake data generator Go libraries, a design philosophy of thislibrary is to allow fine-grained control over generated data.
Let's illustrate this with an example. Instead of having separate functions togenerate IPv4 and IPv6 addresses (e.g.fake.IPv4()
andfake.IPv6()
), thereis a singlefake.IP()
function. However, this generator function, like mostothers, can take optional arguments. By default, i.e. when no option isspecified (fake.IP()
), it generates a random IP address which can be either v4or v6. However, when passing the option to generate IPv4 addresses only(fake.IP(fake.WithIPv4())
option, only v4 addresses are generated. It is alsopossible to pass an option to specify a CIDR that randomly generated IPaddresses must belong to (e.g.fake.IP(fake.WithIPCIDR("10.0.0.0/8"))
).
Compared to other fake data generator Go libraries such asgithub.com/icrowley/fake
orgithub.com/bxcodec/faker
, this library does not (yet) supportas many generators (contributions welcome!).
Go needs to be installed. Then, from either the root directory or thecmd
subdirectory, thefake
binary can be compiled and installed via theinstall
make target. E.g.
make install
By default, it installs the binary to/usr/local/bin/fake
. The destinationdirectory can be specified using theBINDIR
environment variable, e.g.:
BINDIR=~/.local/bin make install
About
A Go library to generate random data for testing and/or performance evaluation