Jabufaker is a package for generating a fake sample data. Data generated based on Indonesia country.
And also this package is build based on developer (Rizky Darmawan)
anxiety in thinking about what sample data to include in an application that is being developed.
The beginning of code in this package, obtained when followed a course udemy with title Backend Master Class [Golang + Postgres + Kubernetes + gRPC]
.
You will find beginning the code this package in there. And me added some code to generate some data I needed. You also can use and contribute by adding some code you need to this package.
Criticism and suggestions about this package are very useful for me. My contacts can be found in the overview section of this repository.
To install jabufaker package, follow these steps:
- You can use the below Go command:
go get -u github.com/rizkydarmawan-letenk/jabufaker
- Import it in your code:
import "github.com/rizkydarmawan-letenk/jabufaker"
This function is used to generate a number integer.
RandomInt(min, max)
min
is minimal number to be generated.max
is maximal number to be generated.
Example:
randInt := jabufaker.RandomInt(0, 100)
fmt.Println(randInt)
This function is used to generate a string.
RandomString(n)
n
is much string to be generated.
Example:
randString := jabufaker.RandomString(10)
fmt.Println(randString)
This function is used to generate a name person.
RandomPerson()
Example:
randPerson := jabufaker.RandomPerson()
fmt.Println(randPerson)
This function is used to generate a random number integer start from 0 to 100.
RandomMoney()
Example:
randMoney := jabufaker.RandomMoney()
fmt.Println(randMoney)
This function is used to generate a random currency. Currently only available IDR, USD, EUR.
RandomCurrency()
Example:
randCurrencies := jabufaker.RandomCurrency()
fmt.Println(randCurrencies)
This function is used to generate random email address.
RandomEmail()
Example:
randEmail := jabufaker.RandomEmail()
fmt.Println(randEmail)
This function is used to generate random province. Note: Currently only available some provinces are based on Sumatera Island.
RandomProvince()
Example:
randProvince := jabufaker.RandomProvince()
fmt.Println(randProvince)
This function is used to generate random regencies, which is the regencies generated based on provinces selected from function RandomProvince().
Note: Make sure before generating random regencies, first generate provinces and make as argument on function RandomRegencies().
RandomRegency(random_province_selected)
Example:
randProvince := jabufaker.RandomProvince()
randRegency := jabufaker.RandomRegency(randProvince)
fmt.Println(randRegency)