Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A Go library to generate random data for testing and/or performance evaluation

License

NotificationsYou must be signed in to change notification settings

cilium/fake

Repository files navigation

Go ReferenceCIGo Report Card

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!).

Installing the CLI

Go needs to be installed. Then, from either the root directory or thecmdsubdirectory, thefake binary can be compiled and installed via theinstallmake 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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp