go-faker
go-faker can generate all kinds of mock data, which is good for testing scenarios.
For example, when you need a fake user record in order to complete some kind of registration process unit test, you can use.
|
|
This gives you a user record with a limited but almost sufficient number of fields.
Installation
Using the docker run will work immediately, as long as you can pull the image from the docker hub without any problems.
|
|
If you prefer to pull mirrors from GitHub’s Registry, that’s fine.
|
|
If you are using a macOS environment, you can install it by way of Homebrew at
However, the M1 environment may not be supported.
For other OS environments, download the pre-compiled binary package from the Releases page.
If there is no pre-compiled binary package, you can only get your executable by compiling the source code, which requires that you have the golang compiler environment installed at
|
|
There is always something for you in the above approaches.
Background
The go-faker is implemented via dmgk/faker. Our version is just a shell of an executable with a proper wrapper.
go-faker currently supports almost all dmgk/faker data, except for date and time, both of which are easier to mock using the OS’s own date command.
The available go-faker commands are as follows.
|
|
It can be used as follows.
|
|
You can also output yaml format, etc.
Command Line Arguments
Proper overwrap means that we have a set of command line arguments that are intuitively idiomatic and conform to POSIX conventions for supplying them.
As an example, a credit card number might look like this.
|
|
You can choose the desired output format, json or json-compact, or yaml format.
For the finance command, you can output credit card numbers in the following format.
Please make your own choice.
Other faked records are listed in the same way, so they are not listed here.
You can check the home pages of go-faker and dmgk/faker respectively for more information.