diff --git a/BENCHMARKS.md b/BENCHMARKS.md
index 2568ecf0..c39bf83c 100644
--- a/BENCHMARKS.md
+++ b/BENCHMARKS.md
@@ -1,458 +1,329 @@
go test -bench=. -benchmem
-goos: linux
+goos: darwin
goarch: amd64
-pkg: github.com/brianvoe/gofakeit/v6
-cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
-Table generated with tablesgenerator.com/markdown_tables
+pkg: github.com/brianvoe/gofakeit/v7
+cpu: Apple M1 Max
+Table generated with tablesgenerator.com/markdown_tables File->Paste table data
-| Benchmark | Ops | CPU | MEM | MEM alloc |
-|--------------------------------------------------|------------|------------------|----------------|-------------------|
-| BenchmarkAddress/package-8 | 1270872 | 940.1 ns/op | 197 B/op | 5 allocs/op |
-| BenchmarkAddress/Faker_math-8 | 1238563 | 1042 ns/op | 197 B/op | 5 allocs/op |
-| BenchmarkAddress/Faker_crypto-8 | 139857 | 7862 ns/op | 197 B/op | 5 allocs/op |
-| BenchmarkStreet/package-8 | 2955518 | 422.6 ns/op | 26 B/op | 2 allocs/op |
-| BenchmarkStreet/Faker_math-8 | 3027224 | 427.3 ns/op | 26 B/op | 2 allocs/op |
-| BenchmarkStreet/Faker_crypto-8 | 352165 | 3559 ns/op | 26 B/op | 2 allocs/op |
-| BenchmarkStreetNumber/package-8 | 6842211 | 149.2 ns/op | 4 B/op | 1 allocs/op |
-| BenchmarkStreetNumber/Faker_math-8 | 6924288 | 158.8 ns/op | 4 B/op | 1 allocs/op |
-| BenchmarkStreetNumber/Faker_crypto-8 | 549988 | 1900 ns/op | 4 B/op | 1 allocs/op |
-| BenchmarkStreetPrefix/package-8 | 18441643 | 74.12 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkStreetPrefix/Faker_math-8 | 17888110 | 67.51 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkStreetPrefix/Faker_crypto-8 | 2650390 | 458.9 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkStreetName/package-8 | 18799832 | 62.90 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkStreetName/Faker_math-8 | 16124620 | 63.57 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkStreetName/Faker_crypto-8 | 2873138 | 428.2 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkStreetSuffix/package-8 | 17192164 | 72.19 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkStreetSuffix/Faker_math-8 | 16545355 | 65.44 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkStreetSuffix/Faker_crypto-8 | 2986934 | 450.9 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCity/package-8 | 18553683 | 64.93 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCity/Faker_math-8 | 17648109 | 63.77 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCity/Faker_crypto-8 | 2567427 | 470.8 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkState/package-8 | 18262387 | 66.25 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkState/Faker_math-8 | 16690209 | 73.21 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkState/Faker_crypto-8 | 2599795 | 401.3 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkStateAbr/package-8 | 17492332 | 63.87 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkStateAbr/Faker_math-8 | 18612169 | 64.82 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkStateAbr/Faker_crypto-8 | 2821579 | 460.0 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkZip/package-8 | 7573238 | 157.1 ns/op | 5 B/op | 1 allocs/op |
-| BenchmarkZip/Faker_math-8 | 6644562 | 163.4 ns/op | 5 B/op | 1 allocs/op |
-| BenchmarkZip/Faker_crypto-8 | 484525 | 2470 ns/op | 5 B/op | 1 allocs/op |
-| BenchmarkCountry/package-8 | 15623450 | 65.65 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCountry/Faker_math-8 | 17786485 | 76.22 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCountry/Faker_crypto-8 | 3002818 | 400.3 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCountryAbr/package-8 | 17296935 | 66.75 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCountryAbr/Faker_math-8 | 17862819 | 67.41 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCountryAbr/Faker_crypto-8 | 2931120 | 426.0 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLatitude/package-8 | 46248466 | 26.11 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLatitude/Faker_math-8 | 46120956 | 26.00 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLatitude/Faker_crypto-8 | 3512108 | 366.7 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLongitude/package-8 | 47443129 | 24.03 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLongitude/Faker_math-8 | 46691144 | 24.64 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLongitude/Faker_crypto-8 | 3501789 | 365.8 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLatitudeInRange/package-8 | 44125588 | 26.96 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLatitudeInRange/Faker_math-8 | 40113348 | 27.36 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLatitudeInRange/Faker_crypto-8 | 3227358 | 378.4 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLongitudeInRange/package-8 | 38948743 | 32.36 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLongitudeInRange/Faker_math-8 | 36491187 | 27.86 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLongitudeInRange/Faker_crypto-8 | 3004773 | 350.4 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkPetName/package-8 | 23445927 | 60.81 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkPetName/Faker_math-8 | 23982228 | 53.68 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkPetName/Faker_crypto-8 | 2681886 | 458.0 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkAnimal/package-8 | 23230071 | 55.13 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkAnimal/Faker_math-8 | 21923606 | 53.10 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkAnimal/Faker_crypto-8 | 2680177 | 411.6 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkAnimalType/package-8 | 18826995 | 53.45 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkAnimalType/Faker_math-8 | 22170756 | 63.39 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkAnimalType/Faker_crypto-8 | 2780270 | 399.6 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkFarmAnimal/package-8 | 18548028 | 64.87 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkFarmAnimal/Faker_math-8 | 17291526 | 62.47 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkFarmAnimal/Faker_crypto-8 | 2543520 | 409.9 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCat/package-8 | 21213028 | 68.91 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCat/Faker_math-8 | 19973062 | 58.74 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCat/Faker_crypto-8 | 2985601 | 405.2 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkDog/package-8 | 16995627 | 68.15 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkDog/Faker_math-8 | 17296502 | 81.35 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkDog/Faker_crypto-8 | 2530860 | 433.1 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBird/package-8 | 14445968 | 81.31 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBird/Faker_math-8 | 14545851 | 82.69 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBird/Faker_crypto-8 | 2892721 | 420.4 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkAppName/package-8 | 2799828 | 438.6 ns/op | 25 B/op | 1 allocs/op |
-| BenchmarkAppName/Faker_math-8 | 2784135 | 431.1 ns/op | 25 B/op | 1 allocs/op |
-| BenchmarkAppName/Faker_crypto-8 | 611072 | 1923 ns/op | 25 B/op | 1 allocs/op |
-| BenchmarkAppVersion/package-8 | 7552165 | 154.1 ns/op | 7 B/op | 1 allocs/op |
-| BenchmarkAppVersion/Faker_math-8 | 8020767 | 156.6 ns/op | 7 B/op | 1 allocs/op |
-| BenchmarkAppVersion/Faker_crypto-8 | 875899 | 1209 ns/op | 7 B/op | 1 allocs/op |
-| BenchmarkAppAuthor/package-8 | 9596493 | 119.7 ns/op | 8 B/op | 0 allocs/op |
-| BenchmarkAppAuthor/Faker_math-8 | 10068729 | 121.0 ns/op | 8 B/op | 0 allocs/op |
-| BenchmarkAppAuthor/Faker_crypto-8 | 1212542 | 983.7 ns/op | 8 B/op | 0 allocs/op |
-| BenchmarkUsername/package-8 | 6687600 | 174.6 ns/op | 16 B/op | 2 allocs/op |
-| BenchmarkUsername/Faker_math-8 | 7233685 | 173.3 ns/op | 16 B/op | 2 allocs/op |
-| BenchmarkUsername/Faker_crypto-8 | 616884 | 2166 ns/op | 16 B/op | 2 allocs/op |
-| BenchmarkPassword/package-8 | 2966407 | 401.0 ns/op | 336 B/op | 6 allocs/op |
-| BenchmarkPassword/Faker_math-8 | 3080845 | 399.8 ns/op | 336 B/op | 6 allocs/op |
-| BenchmarkPassword/Faker_crypto-8 | 182074 | 5963 ns/op | 336 B/op | 6 allocs/op |
-| BenchmarkBeerName/package-8 | 23768442 | 53.26 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerName/Faker_math-8 | 22010898 | 63.87 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerName/Faker_crypto-8 | 2569424 | 392.6 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerStyle/package-8 | 17567354 | 69.64 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerStyle/Faker_math-8 | 16695721 | 80.73 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerStyle/Faker_crypto-8 | 2710214 | 407.6 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerHop/package-8 | 20877854 | 56.43 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerHop/Faker_math-8 | 22603234 | 65.04 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerHop/Faker_crypto-8 | 2618493 | 419.3 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerYeast/package-8 | 20738073 | 67.89 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerYeast/Faker_math-8 | 21325231 | 67.34 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerYeast/Faker_crypto-8 | 3042529 | 399.8 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerMalt/package-8 | 15756969 | 65.67 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerMalt/Faker_math-8 | 18026910 | 71.42 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerMalt/Faker_crypto-8 | 2949741 | 429.4 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBeerIbu/package-8 | 32683443 | 35.57 ns/op | 8 B/op | 1 allocs/op |
-| BenchmarkBeerIbu/Faker_math-8 | 29983339 | 36.03 ns/op | 8 B/op | 1 allocs/op |
-| BenchmarkBeerIbu/Faker_crypto-8 | 3094896 | 386.6 ns/op | 8 B/op | 1 allocs/op |
-| BenchmarkBeerAlcohol/package-8 | 4744302 | 243.6 ns/op | 32 B/op | 3 allocs/op |
-| BenchmarkBeerAlcohol/Faker_math-8 | 4718923 | 252.0 ns/op | 32 B/op | 3 allocs/op |
-| BenchmarkBeerAlcohol/Faker_crypto-8 | 1952740 | 656.0 ns/op | 32 B/op | 3 allocs/op |
-| BenchmarkBeerBlg/package-8 | 4086861 | 270.6 ns/op | 40 B/op | 3 allocs/op |
-| BenchmarkBeerBlg/Faker_math-8 | 4488897 | 259.5 ns/op | 40 B/op | 3 allocs/op |
-| BenchmarkBeerBlg/Faker_crypto-8 | 1865367 | 646.7 ns/op | 40 B/op | 3 allocs/op |
-| BenchmarkCar/package-8 | 2800782 | 400.5 ns/op | 96 B/op | 1 allocs/op |
-| BenchmarkCar/Faker_math-8 | 2938509 | 396.5 ns/op | 96 B/op | 1 allocs/op |
-| BenchmarkCar/Faker_crypto-8 | 461906 | 2590 ns/op | 96 B/op | 1 allocs/op |
-| BenchmarkCarType/package-8 | 23655384 | 51.72 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarType/Faker_math-8 | 25902462 | 50.55 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarType/Faker_crypto-8 | 3035287 | 455.8 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarFuelType/package-8 | 18750069 | 63.80 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarFuelType/Faker_math-8 | 18858705 | 63.15 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarFuelType/Faker_crypto-8 | 3028026 | 387.0 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarTransmissionType/package-8 | 22570701 | 54.01 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarTransmissionType/Faker_math-8 | 21484246 | 64.27 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarTransmissionType/Faker_crypto-8 | 3061364 | 387.6 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarMaker/package-8 | 17628445 | 68.23 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarMaker/Faker_math-8 | 21573310 | 64.19 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarMaker/Faker_crypto-8 | 2688284 | 475.5 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarModel/package-8 | 18500498 | 73.43 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarModel/Faker_math-8 | 16116993 | 66.91 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCarModel/Faker_crypto-8 | 2487638 | 440.0 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCelebrityActor/package-8 | 18712833 | 74.12 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCelebrityActor/Faker_math-8 | 18564168 | 68.96 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCelebrityActor/Faker_crypto-8 | 2593150 | 415.5 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCelebrityBusiness/package-8 | 18721152 | 68.98 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCelebrityBusiness/Faker_math-8 | 16916186 | 70.66 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCelebrityBusiness/Faker_crypto-8 | 2578786 | 407.7 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCelebritySport/package-8 | 16716724 | 87.51 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCelebritySport/Faker_math-8 | 16602294 | 86.41 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCelebritySport/Faker_crypto-8 | 2919696 | 419.0 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkColor/package-8 | 17871778 | 62.28 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkColor/Faker_math-8 | 21601353 | 62.63 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkColor/Faker_crypto-8 | 3040459 | 463.1 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkNiceColors/package-8 | 81438092 | 14.86 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkNiceColors/Faker_math-8 | 75775309 | 18.52 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkNiceColors/Faker_crypto-8 | 3450939 | 353.9 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkSafeColor/package-8 | 22775230 | 53.52 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkSafeColor/Faker_math-8 | 24526308 | 59.40 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkSafeColor/Faker_crypto-8 | 3103851 | 413.3 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHexColor/package-8 | 4640522 | 255.2 ns/op | 24 B/op | 3 allocs/op |
-| BenchmarkHexColor/Faker_math-8 | 4723542 | 257.2 ns/op | 24 B/op | 3 allocs/op |
-| BenchmarkHexColor/Faker_crypto-8 | 283828 | 4447 ns/op | 24 B/op | 3 allocs/op |
-| BenchmarkRGBColor/package-8 | 19721971 | 59.64 ns/op | 24 B/op | 1 allocs/op |
-| BenchmarkRGBColor/Faker_math-8 | 18808492 | 67.35 ns/op | 24 B/op | 1 allocs/op |
-| BenchmarkRGBColor/Faker_crypto-8 | 1000000 | 1066 ns/op | 24 B/op | 1 allocs/op |
-| BenchmarkCompany/package-8 | 22072651 | 48.06 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCompany/Faker_math-8 | 22528284 | 53.94 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCompany/Faker_crypto-8 | 2690668 | 402.4 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCompanySuffix/package-8 | 28169413 | 48.00 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCompanySuffix/Faker_math-8 | 20685153 | 52.20 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCompanySuffix/Faker_crypto-8 | 3018765 | 418.0 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBuzzWord/package-8 | 24238677 | 54.55 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBuzzWord/Faker_math-8 | 22195419 | 52.30 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBuzzWord/Faker_crypto-8 | 2840428 | 392.1 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBS/package-8 | 23481436 | 56.33 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBS/Faker_math-8 | 23195737 | 65.66 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBS/Faker_crypto-8 | 3027972 | 419.8 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkJob/package-8 | 4432520 | 253.5 ns/op | 64 B/op | 1 allocs/op |
-| BenchmarkJob/Faker_math-8 | 4513154 | 253.7 ns/op | 64 B/op | 1 allocs/op |
-| BenchmarkJob/Faker_crypto-8 | 686028 | 1716 ns/op | 64 B/op | 1 allocs/op |
-| BenchmarkJobTitle/package-8 | 20079558 | 54.21 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkJobTitle/Faker_math-8 | 21871627 | 54.86 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkJobTitle/Faker_crypto-8 | 3017896 | 413.3 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkJobDescriptor/package-8 | 21579855 | 53.36 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkJobDescriptor/Faker_math-8 | 24638751 | 55.91 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkJobDescriptor/Faker_crypto-8 | 2984810 | 415.9 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkJobLevel/package-8 | 18311070 | 59.35 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkJobLevel/Faker_math-8 | 17051210 | 59.53 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkJobLevel/Faker_crypto-8 | 2991106 | 426.8 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCSVLookup100-8 | 1468 | 780852 ns/op | 437416 B/op | 5933 allocs/op |
-| BenchmarkCSVLookup1000-8 | 151 | 7853471 ns/op | 4224820 B/op | 59612 allocs/op |
-| BenchmarkCSVLookup10000-8 | 14 | 78165009 ns/op | 41208010 B/op | 597842 allocs/op |
-| BenchmarkCSVLookup100000-8 | 2 | 768800840 ns/op | 437275164 B/op | 5980461 allocs/op |
-| BenchmarkEmoji/package-8 | 22212386 | 54.40 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmoji/Faker_math-8 | 21471013 | 51.55 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmoji/Faker_crypto-8 | 3036081 | 458.1 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmojiDescription/package-8 | 18250413 | 57.08 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmojiDescription/Faker_math-8 | 21924381 | 57.58 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmojiDescription/Faker_crypto-8 | 2837050 | 387.5 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmojiCategory/package-8 | 21270252 | 55.87 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmojiCategory/Faker_math-8 | 21421813 | 59.59 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmojiCategory/Faker_crypto-8 | 2635878 | 491.0 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmojiAlias/package-8 | 18760875 | 68.20 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmojiAlias/Faker_math-8 | 16918242 | 67.60 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmojiAlias/Faker_crypto-8 | 2854717 | 488.9 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmojiTag/package-8 | 19953885 | 65.43 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmojiTag/Faker_math-8 | 18220396 | 72.91 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkEmojiTag/Faker_crypto-8 | 2802847 | 426.2 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkError/package-8 | 1547610 | 786.6 ns/op | 279 B/op | 8 allocs/op |
-| BenchmarkError/Faker_math-8 | 1504578 | 794.1 ns/op | 279 B/op | 8 allocs/op |
-| BenchmarkError/Faker_crypto-8 | 800712 | 1476 ns/op | 279 B/op | 8 allocs/op |
-| BenchmarkErrorObject/package-8 | 6054552 | 190.3 ns/op | 32 B/op | 3 allocs/op |
-| BenchmarkErrorObject/Faker_math-8 | 5968180 | 190.3 ns/op | 32 B/op | 3 allocs/op |
-| BenchmarkErrorObject/Faker_crypto-8 | 2088008 | 618.0 ns/op | 32 B/op | 3 allocs/op |
-| BenchmarkErrorDatabase/package-8 | 5275713 | 212.8 ns/op | 64 B/op | 3 allocs/op |
-| BenchmarkErrorDatabase/Faker_math-8 | 5407803 | 217.3 ns/op | 64 B/op | 3 allocs/op |
-| BenchmarkErrorDatabase/Faker_crypto-8 | 2005333 | 628.7 ns/op | 63 B/op | 3 allocs/op |
-| BenchmarkErrorGRPC/package-8 | 5700810 | 202.9 ns/op | 64 B/op | 3 allocs/op |
-| BenchmarkErrorGRPC/Faker_math-8 | 5907589 | 202.5 ns/op | 64 B/op | 3 allocs/op |
-| BenchmarkErrorGRPC/Faker_crypto-8 | 2027650 | 643.3 ns/op | 64 B/op | 3 allocs/op |
-| BenchmarkErrorHTTP/package-8 | 3182026 | 321.6 ns/op | 157 B/op | 4 allocs/op |
-| BenchmarkErrorHTTP/Faker_math-8 | 3667356 | 314.9 ns/op | 157 B/op | 4 allocs/op |
-| BenchmarkErrorHTTP/Faker_crypto-8 | 1590696 | 720.2 ns/op | 157 B/op | 4 allocs/op |
-| BenchmarkErrorHTTPClient/package-8 | 5745494 | 204.0 ns/op | 52 B/op | 3 allocs/op |
-| BenchmarkErrorHTTPClient/Faker_math-8 | 5549187 | 212.8 ns/op | 52 B/op | 3 allocs/op |
-| BenchmarkErrorHTTPClient/Faker_crypto-8 | 2011905 | 596.7 ns/op | 52 B/op | 3 allocs/op |
-| BenchmarkErrorHTTPServer/package-8 | 5466012 | 214.7 ns/op | 59 B/op | 3 allocs/op |
-| BenchmarkErrorHTTPServer/Faker_math-8 | 5542838 | 207.3 ns/op | 59 B/op | 3 allocs/op |
-| BenchmarkErrorHTTPServer/Faker_crypto-8 | 1939080 | 633.9 ns/op | 59 B/op | 3 allocs/op |
-| BenchmarkErrorRuntime/package-8 | 4245986 | 263.4 ns/op | 150 B/op | 3 allocs/op |
-| BenchmarkErrorRuntime/Faker_math-8 | 4355534 | 263.1 ns/op | 150 B/op | 3 allocs/op |
-| BenchmarkErrorRuntime/Faker_crypto-8 | 1782044 | 651.4 ns/op | 150 B/op | 3 allocs/op |
-| BenchmarkErrorValidation/package-8 | 1659858 | 715.7 ns/op | 268 B/op | 7 allocs/op |
-| BenchmarkErrorValidation/Faker_math-8 | 1690849 | 716.4 ns/op | 268 B/op | 7 allocs/op |
-| BenchmarkErrorValidation/Faker_crypto-8 | 883600 | 1348 ns/op | 268 B/op | 7 allocs/op |
-| BenchmarkFileMimeType/package-8 | 18005230 | 56.88 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkFileMimeType/Faker_math-8 | 21229381 | 54.62 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkFileMimeType/Faker_crypto-8 | 2605701 | 462.5 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkFileExtension/package-8 | 19272264 | 73.07 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkFileExtension/Faker_math-8 | 20149288 | 60.79 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkFileExtension/Faker_crypto-8 | 2627210 | 423.1 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkCusip/package-8 | 5402995 | 224.9 ns/op | 24 B/op | 2 allocs/op |
-| BenchmarkCusip/Faker_math-8 | 5367218 | 221.1 ns/op | 24 B/op | 2 allocs/op |
-| BenchmarkCusip/Faker_crypto-8 | 363460 | 2967 ns/op | 24 B/op | 2 allocs/op |
-| BenchmarkIsin/package-8 | 1742368 | 701.4 ns/op | 533 B/op | 8 allocs/op |
-| BenchmarkIsin/Faker_math-8 | 1653408 | 715.5 ns/op | 533 B/op | 8 allocs/op |
-| BenchmarkIsin/Faker_crypto-8 | 330396 | 3583 ns/op | 533 B/op | 8 allocs/op |
-| BenchmarkFruit/package-8 | 21421066 | 55.23 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkFruit/Faker_math-8 | 22680361 | 55.68 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkFruit/Faker_crypto-8 | 2914611 | 486.7 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkVegetable/package-8 | 21113413 | 56.44 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkVegetable/Faker_math-8 | 21101716 | 60.98 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkVegetable/Faker_crypto-8 | 2811384 | 467.1 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBreakfast/package-8 | 8954784 | 127.7 ns/op | 32 B/op | 1 allocs/op |
-| BenchmarkBreakfast/Faker_math-8 | 9430814 | 128.8 ns/op | 32 B/op | 1 allocs/op |
-| BenchmarkBreakfast/Faker_crypto-8 | 2132481 | 496.5 ns/op | 32 B/op | 1 allocs/op |
-| BenchmarkLunch/package-8 | 8934501 | 125.9 ns/op | 34 B/op | 1 allocs/op |
-| BenchmarkLunch/Faker_math-8 | 8668546 | 128.9 ns/op | 34 B/op | 1 allocs/op |
-| BenchmarkLunch/Faker_crypto-8 | 2216348 | 518.3 ns/op | 34 B/op | 1 allocs/op |
-| BenchmarkDinner/package-8 | 9317936 | 125.2 ns/op | 36 B/op | 1 allocs/op |
-| BenchmarkDinner/Faker_math-8 | 9023473 | 126.3 ns/op | 36 B/op | 1 allocs/op |
-| BenchmarkDinner/Faker_crypto-8 | 2435984 | 518.9 ns/op | 36 B/op | 1 allocs/op |
-| BenchmarkDrink/package-8 | 7698025 | 143.4 ns/op | 7 B/op | 2 allocs/op |
-| BenchmarkDrink/Faker_math-8 | 8096294 | 139.8 ns/op | 7 B/op | 2 allocs/op |
-| BenchmarkDrink/Faker_crypto-8 | 2247427 | 536.2 ns/op | 7 B/op | 2 allocs/op |
-| BenchmarkSnack/package-8 | 8109601 | 149.2 ns/op | 32 B/op | 1 allocs/op |
-| BenchmarkSnack/Faker_math-8 | 7993006 | 150.5 ns/op | 32 B/op | 1 allocs/op |
-| BenchmarkSnack/Faker_crypto-8 | 2214736 | 535.7 ns/op | 32 B/op | 1 allocs/op |
-| BenchmarkDessert/package-8 | 8295364 | 133.9 ns/op | 31 B/op | 2 allocs/op |
-| BenchmarkDessert/Faker_math-8 | 8610325 | 134.1 ns/op | 31 B/op | 2 allocs/op |
-| BenchmarkDessert/Faker_crypto-8 | 2205777 | 507.4 ns/op | 31 B/op | 2 allocs/op |
-| BenchmarkGamertag/package-8 | 2111506 | 544.8 ns/op | 83 B/op | 5 allocs/op |
-| BenchmarkGamertag/Faker_math-8 | 2203573 | 551.4 ns/op | 83 B/op | 5 allocs/op |
-| BenchmarkGamertag/Faker_crypto-8 | 487366 | 2428 ns/op | 83 B/op | 5 allocs/op |
-| BenchmarkDice/package-8 | 43259642 | 26.58 ns/op | 8 B/op | 1 allocs/op |
-| BenchmarkDice/Faker_math-8 | 42908084 | 26.84 ns/op | 8 B/op | 1 allocs/op |
-| BenchmarkDice/Faker_crypto-8 | 2953483 | 395.5 ns/op | 8 B/op | 1 allocs/op |
-| BenchmarkGenerate/package-8 | 383122 | 2767 ns/op | 1139 B/op | 29 allocs/op |
-| BenchmarkGenerate/Complex-8 | 135508 | 8555 ns/op | 4440 B/op | 80 allocs/op |
-| BenchmarkGenerate/Faker_math-8 | 377151 | 2817 ns/op | 1139 B/op | 29 allocs/op |
-| BenchmarkGenerate/Faker_crypto-8 | 152226 | 7234 ns/op | 1139 B/op | 29 allocs/op |
-| BenchmarkRegex/package-8 | 628683 | 1922 ns/op | 1632 B/op | 27 allocs/op |
-| BenchmarkRegex/Faker_math-8 | 591548 | 1940 ns/op | 1632 B/op | 27 allocs/op |
-| BenchmarkRegex/Faker_crypto-8 | 616701 | 1934 ns/op | 1632 B/op | 27 allocs/op |
-| BenchmarkRegexEmail/package-8 | 174812 | 6607 ns/op | 4084 B/op | 90 allocs/op |
-| BenchmarkRegexEmail/Faker_math-8 | 174512 | 6619 ns/op | 4084 B/op | 90 allocs/op |
-| BenchmarkRegexEmail/Faker_crypto-8 | 62312 | 18793 ns/op | 4083 B/op | 90 allocs/op |
-| BenchmarkMap/package-8 | 318559 | 3275 ns/op | 1113 B/op | 16 allocs/op |
-| BenchmarkMap/Faker_math-8 | 315990 | 3319 ns/op | 1113 B/op | 16 allocs/op |
-| BenchmarkMap/Faker_crypto-8 | 46202 | 23997 ns/op | 1115 B/op | 16 allocs/op |
-| BenchmarkHackerPhrase/package-8 | 155998 | 7191 ns/op | 3004 B/op | 50 allocs/op |
-| BenchmarkHackerPhrase/Faker_math-8 | 154675 | 7305 ns/op | 3008 B/op | 50 allocs/op |
-| BenchmarkHackerPhrase/Faker_crypto-8 | 109282 | 10268 ns/op | 3007 B/op | 50 allocs/op |
-| BenchmarkHackerAbbreviation/package-8 | 21881574 | 57.57 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackerAbbreviation/Faker_math-8 | 18534495 | 59.55 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackerAbbreviation/Faker_crypto-8 | 2607735 | 401.6 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackerAdjective/package-8 | 24286845 | 55.74 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackerAdjective/Faker_math-8 | 22684101 | 55.22 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackerAdjective/Faker_crypto-8 | 2953530 | 490.5 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackerNoun/package-8 | 22554241 | 55.35 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackerNoun/Faker_math-8 | 18360708 | 56.78 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackerNoun/Faker_crypto-8 | 2823256 | 464.8 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackerVerb/package-8 | 19236123 | 65.49 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackerVerb/Faker_math-8 | 18090754 | 68.18 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackerVerb/Faker_crypto-8 | 2880181 | 439.2 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackeringVerb/package-8 | 19090326 | 71.74 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackeringVerb/Faker_math-8 | 19048659 | 63.31 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHackeringVerb/Faker_crypto-8 | 3020748 | 404.5 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkReplaceWithNumbers-8 | 162931 | 7098 ns/op | 32 B/op | 2 allocs/op |
-| BenchmarkHipsterWord/package-8 | 24059244 | 54.69 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHipsterWord/Faker_math-8 | 21708511 | 52.98 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHipsterWord/Faker_crypto-8 | 2870858 | 396.1 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHipsterSentence/package-8 | 1278764 | 927.7 ns/op | 288 B/op | 3 allocs/op |
-| BenchmarkHipsterSentence/Faker_math-8 | 1287939 | 955.0 ns/op | 288 B/op | 3 allocs/op |
-| BenchmarkHipsterSentence/Faker_crypto-8 | 237703 | 4595 ns/op | 288 B/op | 3 allocs/op |
-| BenchmarkHipsterParagraph/package-8 | 57895 | 18466 ns/op | 10521 B/op | 48 allocs/op |
-| BenchmarkHipsterParagraph/Faker_math-8 | 61772 | 19188 ns/op | 10520 B/op | 48 allocs/op |
-| BenchmarkHipsterParagraph/Faker_crypto-8 | 12978 | 91733 ns/op | 10522 B/op | 48 allocs/op |
-| BenchmarkInputName/package-8 | 15728428 | 74.49 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkInputName/Faker_math-8 | 13243030 | 89.75 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkInputName/Faker_crypto-8 | 2736225 | 478.4 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkSvg/package-8 | 172828 | 7906 ns/op | 8871 B/op | 52 allocs/op |
-| BenchmarkSvg/Faker_math-8 | 161821 | 6754 ns/op | 8875 B/op | 52 allocs/op |
-| BenchmarkSvg/Faker_crypto-8 | 29023 | 40910 ns/op | 8862 B/op | 52 allocs/op |
-| BenchmarkImageURL/package-8 | 11692422 | 94.34 ns/op | 38 B/op | 3 allocs/op |
-| BenchmarkImageURL/Faker_math-8 | 11451087 | 91.39 ns/op | 38 B/op | 3 allocs/op |
-| BenchmarkImageURL/Faker_crypto-8 | 12107578 | 92.30 ns/op | 38 B/op | 3 allocs/op |
-| BenchmarkImage/package-8 | 50 | 20495942 ns/op | 2457673 B/op | 307202 allocs/op |
-| BenchmarkImage/Faker_math-8 | 51 | 20349126 ns/op | 2457780 B/op | 307202 allocs/op |
-| BenchmarkImage/Faker_crypto-8 | 3 | 393591549 ns/op | 2457685 B/op | 307202 allocs/op |
-| BenchmarkImageJpeg/package-8 | 31 | 32857846 ns/op | 2982318 B/op | 307214 allocs/op |
-| BenchmarkImageJpeg/Faker_math-8 | 34 | 31873165 ns/op | 2982479 B/op | 307214 allocs/op |
-| BenchmarkImageJpeg/Faker_crypto-8 | 3 | 387670345 ns/op | 2982357 B/op | 307215 allocs/op |
-| BenchmarkImagePng/package-8 | 16 | 65425256 ns/op | 5899024 B/op | 307270 allocs/op |
-| BenchmarkImagePng/Faker_math-8 | 18 | 67804235 ns/op | 5899314 B/op | 307270 allocs/op |
-| BenchmarkImagePng/Faker_crypto-8 | 3 | 396378778 ns/op | 5899005 B/op | 307270 allocs/op |
-| BenchmarkDomainName/package-8 | 2344912 | 505.6 ns/op | 95 B/op | 5 allocs/op |
-| BenchmarkDomainName/Faker_math-8 | 2265744 | 512.5 ns/op | 95 B/op | 5 allocs/op |
-| BenchmarkDomainName/Faker_crypto-8 | 639775 | 1788 ns/op | 95 B/op | 5 allocs/op |
-| BenchmarkDomainSuffix/package-8 | 19431498 | 59.95 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkDomainSuffix/Faker_math-8 | 20097267 | 59.04 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkDomainSuffix/Faker_crypto-8 | 2498906 | 437.0 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkURL/package-8 | 1000000 | 1155 ns/op | 277 B/op | 10 allocs/op |
-| BenchmarkURL/Faker_math-8 | 1000000 | 1165 ns/op | 277 B/op | 10 allocs/op |
-| BenchmarkURL/Faker_crypto-8 | 275793 | 4371 ns/op | 276 B/op | 10 allocs/op |
-| BenchmarkHTTPMethod/package-8 | 17651594 | 59.20 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHTTPMethod/Faker_math-8 | 20081227 | 61.28 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHTTPMethod/Faker_crypto-8 | 2844322 | 460.1 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkIPv4Address/package-8 | 5215255 | 229.2 ns/op | 16 B/op | 1 allocs/op |
-| BenchmarkIPv4Address/Faker_math-8 | 4852905 | 224.9 ns/op | 16 B/op | 1 allocs/op |
-| BenchmarkIPv4Address/Faker_crypto-8 | 670951 | 1827 ns/op | 16 B/op | 1 allocs/op |
-| BenchmarkIPv6Address/package-8 | 2312482 | 510.0 ns/op | 111 B/op | 8 allocs/op |
-| BenchmarkIPv6Address/Faker_math-8 | 2261472 | 521.2 ns/op | 111 B/op | 8 allocs/op |
-| BenchmarkIPv6Address/Faker_crypto-8 | 338601 | 3623 ns/op | 111 B/op | 8 allocs/op |
-| BenchmarkMacAddress/package-8 | 2809762 | 426.2 ns/op | 24 B/op | 1 allocs/op |
-| BenchmarkMacAddress/Faker_math-8 | 2863842 | 425.5 ns/op | 24 B/op | 1 allocs/op |
-| BenchmarkMacAddress/Faker_crypto-8 | 376604 | 2688 ns/op | 24 B/op | 1 allocs/op |
-| BenchmarkHTTPStatusCode/package-8 | 13488582 | 88.27 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHTTPStatusCode/Faker_math-8 | 14188726 | 73.23 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHTTPStatusCode/Faker_crypto-8 | 2497014 | 463.7 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHTTPStatusCodeSimple/package-8 | 17822486 | 81.54 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHTTPStatusCodeSimple/Faker_math-8 | 16282341 | 70.72 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkHTTPStatusCodeSimple/Faker_crypto-8 | 2360576 | 451.7 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLogLevel/package-8 | 19343472 | 67.40 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLogLevel/Faker_math-8 | 19445798 | 61.84 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLogLevel/Faker_crypto-8 | 2296162 | 468.5 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkUserAgent/package-8 | 1503814 | 813.9 ns/op | 297 B/op | 5 allocs/op |
-| BenchmarkUserAgent/Faker_math-8 | 1462177 | 803.6 ns/op | 298 B/op | 5 allocs/op |
-| BenchmarkUserAgent/Faker_crypto-8 | 181178 | 6157 ns/op | 298 B/op | 5 allocs/op |
-| BenchmarkChromeUserAgent/package-8 | 1911201 | 596.8 ns/op | 184 B/op | 5 allocs/op |
-| BenchmarkChromeUserAgent/Faker_math-8 | 1969712 | 598.1 ns/op | 184 B/op | 5 allocs/op |
-| BenchmarkChromeUserAgent/Faker_crypto-8 | 264816 | 4433 ns/op | 184 B/op | 5 allocs/op |
-| BenchmarkFirefoxUserAgent/package-8 | 1000000 | 1043 ns/op | 362 B/op | 6 allocs/op |
-| BenchmarkFirefoxUserAgent/Faker_math-8 | 1000000 | 1054 ns/op | 362 B/op | 6 allocs/op |
-| BenchmarkFirefoxUserAgent/Faker_crypto-8 | 166128 | 7646 ns/op | 362 B/op | 6 allocs/op |
-| BenchmarkSafariUserAgent/package-8 | 1000000 | 1022 ns/op | 551 B/op | 7 allocs/op |
-| BenchmarkSafariUserAgent/Faker_math-8 | 1000000 | 1017 ns/op | 551 B/op | 7 allocs/op |
-| BenchmarkSafariUserAgent/Faker_crypto-8 | 146463 | 7525 ns/op | 551 B/op | 7 allocs/op |
-| BenchmarkOperaUserAgent/package-8 | 1844185 | 643.8 ns/op | 212 B/op | 5 allocs/op |
-| BenchmarkOperaUserAgent/Faker_math-8 | 1805168 | 654.3 ns/op | 212 B/op | 5 allocs/op |
-| BenchmarkOperaUserAgent/Faker_crypto-8 | 219927 | 5257 ns/op | 212 B/op | 5 allocs/op |
-| BenchmarkJSONLookup100-8 | 894 | 1194698 ns/op | 537673 B/op | 8141 allocs/op |
-| BenchmarkJSONLookup1000-8 | 91 | 12099728 ns/op | 5616708 B/op | 81606 allocs/op |
-| BenchmarkJSONLookup10000-8 | 8 | 128144166 ns/op | 62638763 B/op | 817708 allocs/op |
-| BenchmarkJSONLookup100000-8 | 1 | 1324756016 ns/op | 616116744 B/op | 8179136 allocs/op |
-| BenchmarkLanguage/package-8 | 20946056 | 68.53 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLanguage/Faker_math-8 | 16884613 | 61.06 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLanguage/Faker_crypto-8 | 2889944 | 442.0 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLanguageAbbreviation/package-8 | 20782443 | 53.79 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLanguageAbbreviation/Faker_math-8 | 17936367 | 56.26 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLanguageAbbreviation/Faker_crypto-8 | 2630406 | 423.8 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLanguageBCP/package-8 | 19858063 | 59.00 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLanguageBCP/Faker_math-8 | 20712447 | 60.02 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLanguageBCP/Faker_crypto-8 | 2654044 | 469.2 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkProgrammingLanguage/package-8 | 17849598 | 58.34 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkProgrammingLanguage/Faker_math-8 | 20090289 | 70.59 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkProgrammingLanguage/Faker_crypto-8 | 2628798 | 424.4 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkProgrammingLanguageBest/package-8 | 1000000000 | 0.4044 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkProgrammingLanguageBest/Faker_math-8 | 1000000000 | 0.2975 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkProgrammingLanguageBest/Faker_crypto-8 | 1000000000 | 0.2543 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLoremIpsumWord-8 | 22434632 | 54.96 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkLoremIpsumSentence-8 | 1000000 | 1038 ns/op | 219 B/op | 2 allocs/op |
-| BenchmarkLoremIpsumParagraph-8 | 59320 | 19442 ns/op | 8479 B/op | 40 allocs/op |
-| BenchmarkMinecraftOre/package-8 | 14624242 | 90.01 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftOre/Faker_math-8 | 16379578 | 86.91 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftOre/Faker_crypto-8 | 2757652 | 477.0 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftWood/package-8 | 15815132 | 83.23 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftWood/Faker_math-8 | 14872902 | 75.36 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftWood/Faker_crypto-8 | 2524514 | 514.4 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftArmorTier/package-8 | 15296107 | 78.58 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftArmorTier/Faker_math-8 | 14341870 | 86.33 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftArmorTier/Faker_crypto-8 | 2344278 | 473.1 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftArmorPart/package-8 | 16863422 | 82.04 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftArmorPart/Faker_math-8 | 14052031 | 76.92 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftArmorPart/Faker_crypto-8 | 2770314 | 474.5 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftWeapon/package-8 | 15759004 | 77.42 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftWeapon/Faker_math-8 | 15945940 | 81.48 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftWeapon/Faker_crypto-8 | 2254436 | 464.5 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftTool/package-8 | 15887787 | 76.39 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftTool/Faker_math-8 | 14269508 | 91.01 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftTool/Faker_crypto-8 | 2718507 | 525.7 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftDye/package-8 | 16131942 | 71.06 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftDye/Faker_math-8 | 16802478 | 73.40 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftDye/Faker_crypto-8 | 2584966 | 476.4 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftFood/package-8 | 14680048 | 87.15 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftFood/Faker_math-8 | 13558227 | 86.71 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftFood/Faker_crypto-8 | 2329946 | 435.6 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftAnimal/package-8 | 15871832 | 85.92 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftAnimal/Faker_math-8 | 12411510 | 83.88 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftAnimal/Faker_crypto-8 | 2528960 | 441.9 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftVillagerJob/package-8 | 13549438 | 80.41 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftVillagerJob/Faker_math-8 | 13769702 | 104.5 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftVillagerJob/Faker_crypto-8 | 2397300 | 452.2 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftVillagerStation/package-8 | 15069139 | 93.65 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftVillagerStation/Faker_math-8 | 15468883 | 82.27 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftVillagerStation/Faker_crypto-8 | 2469778 | 453.9 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftVillagerLevel/package-8 | 13468396 | 102.1 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftVillagerLevel/Faker_math-8 | 14354506 | 92.55 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftVillagerLevel/Faker_crypto-8 | 2416441 | 544.5 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftMobPassive/package-8 | 13299806 | 84.84 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftMobPassive/Faker_math-8 | 14181126 | 87.18 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftMobPassive/Faker_crypto-8 | 2539264 | 510.0 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftMobNeutral/package-8 | 11043175 | 110.7 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftMobNeutral/Faker_math-8 | 13059249 | 99.36 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftMobNeutral/Faker_crypto-8 | 2394342 | 544.6 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftMobHostile/package-8 | 13963809 | 95.66 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftMobHostile/Faker_math-8 | 15182318 | 96.90 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftMobHostile/Faker_crypto-8 | 2204600 | 538.3 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftMobBoss/package-8 | 12737437 | 89.68 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftMobBoss/Faker_math-8 | 13494093 | 90.65 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftMobBoss/Faker_crypto-8 | 2671172 | 461.3 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftBiome/package-8 | 13233918 | 81.47 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftBiome/Faker_math-8 | 16109408 | 85.68 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftBiome/Faker_crypto-8 | 2205704 | 499.4 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftWeather/package-8 | 13371518 | 79.93 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftWeather/Faker_math-8 | 14987182 | 80.69 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkMinecraftWeather/Faker_crypto-8 | 2373735 | 473.6 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBool/package-8 | 75772935 | 15.03 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBool/Faker_math-8 | 76893664 | 19.04 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkBool/Faker_crypto-8 | 3141634 | 376.4 ns/op | 0 B/op | 0 allocs/op |
-| BenchmarkUUID/package-8 | 9382911 | 115.3 ns/op | 64 B/op | 2 allocs/op |
-| BenchmarkUUID/Faker_math-8 | 9492183 | 114.1 ns/op | 64 B/op | 2 allocs/op |
-| BenchmarkUUID/Faker_crypto-8 | 1000000 | 1039 ns/op | 64 B/op | 2 allocs/op |
-| BenchmarkShuffleAnySlice/package-8 | 2234314 | 511.5 ns/op | 24 B/op | 1 allocs/op |
\ No newline at end of file
+| Benchmark | Ops | CPU | MEM | MEM alloc |
+|---------------------------------------|----------|----------------|--------------|------------------|
+| BenchmarkAddress-10 | 1375822 | 869.4 ns/op | 195 B/op | 5 allocs/op |
+|---------------------------------------|----------|----------------|--------------|------------------|
+| BenchmarkStreet-10 | 3450486 | 347.3 ns/op | 25 B/op | 2 allocs/op |
+| BenchmarkStreetNumber-10 | 8865484 | 134.7 ns/op | 4 B/op | 1 allocs/op |
+| BenchmarkStreetPrefix-10 | 19342502 | 60.21 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkStreetName-10 | 19748833 | 60.37 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkStreetSuffix-10 | 19729594 | 60.34 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCity-10 | 20015956 | 59.27 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkState-10 | 19448972 | 61.07 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkStateAbr-10 | 19488494 | 61.04 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkZip-10 | 7568804 | 160.8 ns/op | 5 B/op | 1 allocs/op |
+| BenchmarkCountry-10 | 18972093 | 62.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCountryAbr-10 | 19571958 | 69.59 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkLatitude-10 | 61390362 | 19.55 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkLongitude-10 | 61311031 | 19.55 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkLatitudeInRange-10 | 55916792 | 21.42 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkLongitudeInRange-10 | 55720761 | 21.42 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPetName-10 | 20981083 | 55.91 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAnimal-10 | 20565596 | 58.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAnimalType-10 | 19437697 | 63.35 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkFarmAnimal-10 | 16147407 | 73.52 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCat-10 | 17844429 | 67.84 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkDog-10 | 14622160 | 81.74 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBird-10 | 12817699 | 93.56 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAppName-10 | 3149502 | 379.8 ns/op | 25 B/op | 1 allocs/op |
+| BenchmarkAppVersion-10 | 8479448 | 141.4 ns/op | 7 B/op | 1 allocs/op |
+| BenchmarkAppAuthor-10 | 10185164 | 118.4 ns/op | 8 B/op | 0 allocs/op |
+| BenchmarkUsername-10 | 7506927 | 159.2 ns/op | 16 B/op | 2 allocs/op |
+| BenchmarkPassword-10 | 277974 | 4278 ns/op | 1657 B/op | 60 allocs/op |
+| BenchmarkBeerName-10 | 26747800 | 44.92 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBeerStyle-10 | 18350890 | 65.26 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBeerHop-10 | 25144998 | 47.69 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBeerYeast-10 | 23666304 | 50.52 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBeerMalt-10 | 19719030 | 60.68 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBeerIbu-10 | 34583502 | 34.44 ns/op | 8 B/op | 1 allocs/op |
+| BenchmarkBeerAlcohol-10 | 5074156 | 238.5 ns/op | 28 B/op | 2 allocs/op |
+| BenchmarkBeerBlg-10 | 4895299 | 244.9 ns/op | 37 B/op | 2 allocs/op |
+| BenchmarkBook-10 | 5470438 | 219.3 ns/op | 48 B/op | 1 allocs/op |
+| BenchmarkBookTitle-10 | 21608480 | 55.42 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBookAuthor-10 | 20776431 | 57.66 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBookGenre-10 | 16837358 | 71.15 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCar-10 | 3381850 | 354.1 ns/op | 96 B/op | 1 allocs/op |
+| BenchmarkCarType-10 | 24185968 | 49.45 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCarFuelType-10 | 23069048 | 51.91 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCarTransmissionType-10 | 21307764 | 56.23 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCarMaker-10 | 20469315 | 58.53 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCarModel-10 | 16555663 | 72.45 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCelebrityActor-10 | 22965316 | 52.18 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCelebrityBusiness-10 | 21951553 | 54.59 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCelebritySport-10 | 17658906 | 67.81 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkColor-10 | 19688874 | 60.67 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNiceColors-10 | 73932027 | 16.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkSafeColor-10 | 24165553 | 49.60 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkHexColor-10 | 4798290 | 249.1 ns/op | 24 B/op | 3 allocs/op |
+| BenchmarkRGBColor-10 | 19693560 | 61.06 ns/op | 24 B/op | 1 allocs/op |
+| BenchmarkCompany-10 | 25783947 | 46.14 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCompanySuffix-10 | 24720987 | 48.45 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBlurb-10 | 20877235 | 57.81 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBuzzWord-10 | 23336427 | 51.29 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBS-10 | 22074699 | 54.26 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkJob-10 | 4047650 | 295.9 ns/op | 64 B/op | 1 allocs/op |
+| BenchmarkJobTitle-10 | 26408619 | 45.52 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkJobDescriptor-10 | 24977818 | 48.01 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkJobLevel-10 | 20871273 | 57.37 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkSlogan-10 | 4598202 | 260.3 ns/op | 41 B/op | 1 allocs/op |
+| BenchmarkCSVLookup100-10 | 1118 | 1083290 ns/op | 713669 B/op | 9924 allocs/op |
+| BenchmarkEmoji-10 | 22190750 | 53.94 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkEmojiDescription-10 | 21292152 | 56.20 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkEmojiCategory-10 | 19740643 | 60.80 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkEmojiAlias-10 | 16636665 | 71.98 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkEmojiTag-10 | 18367076 | 65.27 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkError-10 | 1585123 | 758.6 ns/op | 288 B/op | 8 allocs/op |
+| BenchmarkErrorObject-10 | 6719510 | 176.0 ns/op | 32 B/op | 3 allocs/op |
+| BenchmarkErrorDatabase-10 | 5866993 | 205.0 ns/op | 64 B/op | 3 allocs/op |
+| BenchmarkErrorGRPC-10 | 5956057 | 201.8 ns/op | 64 B/op | 3 allocs/op |
+| BenchmarkErrorHTTP-10 | 3914607 | 311.2 ns/op | 158 B/op | 4 allocs/op |
+| BenchmarkErrorHTTPClient-10 | 6034057 | 199.7 ns/op | 52 B/op | 3 allocs/op |
+| BenchmarkErrorHTTPServer-10 | 5825484 | 205.8 ns/op | 59 B/op | 3 allocs/op |
+| BenchmarkErrorRuntime-10 | 4678354 | 253.6 ns/op | 150 B/op | 3 allocs/op |
+| BenchmarkErrorValidation-10 | 1745886 | 685.5 ns/op | 277 B/op | 7 allocs/op |
+| BenchmarkFileMimeType-10 | 25133455 | 47.62 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkFileExtension-10 | 20728759 | 57.74 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCusip-10 | 6810276 | 175.2 ns/op | 16 B/op | 1 allocs/op |
+| BenchmarkIsin-10 | 1758177 | 684.4 ns/op | 525 B/op | 7 allocs/op |
+| BenchmarkFruit-10 | 25126088 | 47.61 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkVegetable-10 | 23948730 | 50.03 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBreakfast-10 | 10403901 | 115.6 ns/op | 32 B/op | 1 allocs/op |
+| BenchmarkLunch-10 | 9939966 | 121.6 ns/op | 34 B/op | 1 allocs/op |
+| BenchmarkDinner-10 | 10409384 | 115.7 ns/op | 36 B/op | 1 allocs/op |
+| BenchmarkDrink-10 | 9209277 | 130.0 ns/op | 7 B/op | 2 allocs/op |
+| BenchmarkSnack-10 | 8251453 | 144.8 ns/op | 32 B/op | 1 allocs/op |
+| BenchmarkDessert-10 | 9630193 | 124.5 ns/op | 31 B/op | 2 allocs/op |
+| BenchmarkGamertag-10 | 2490394 | 479.5 ns/op | 83 B/op | 5 allocs/op |
+| BenchmarkDice-10 | 48060315 | 25.16 ns/op | 8 B/op | 1 allocs/op |
+| BenchmarkGenerate/package-10 | 435873 | 2836 ns/op | 1187 B/op | 29 allocs/op |
+| BenchmarkGenerate/Complex-10 | 140688 | 8538 ns/op | 4552 B/op | 80 allocs/op |
+| BenchmarkFixedWidthLookup100-10 | 2074 | 577861 ns/op | 489980 B/op | 8701 allocs/op |
+| BenchmarkRegex-10 | 637093 | 1908 ns/op | 1632 B/op | 27 allocs/op |
+| BenchmarkRegexEmail-10 | 206439 | 5858 ns/op | 4083 B/op | 90 allocs/op |
+| BenchmarkMap-10 | 335659 | 3588 ns/op | 1109 B/op | 16 allocs/op |
+| BenchmarkHackerPhrase-10 | 167949 | 7200 ns/op | 3106 B/op | 50 allocs/op |
+| BenchmarkHackerAbbreviation-10 | 26049344 | 45.87 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkHackerAdjective-10 | 25004623 | 47.90 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkHackerNoun-10 | 23641378 | 50.72 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkHackerVerb-10 | 19799652 | 60.58 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkHackeringVerb-10 | 20966176 | 57.04 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkReplaceWithNumbers-10 | 1393796 | 859.9 ns/op | 296 B/op | 10 allocs/op |
+| BenchmarkHipsterWord-10 | 24402415 | 48.90 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkHipsterSentence-10 | 1306906 | 918.2 ns/op | 288 B/op | 3 allocs/op |
+| BenchmarkHipsterParagraph-10 | 66908 | 18036 ns/op | 10521 B/op | 48 allocs/op |
+| BenchmarkInputName-10 | 20470465 | 58.45 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkSvg-10 | 235867 | 5062 ns/op | 8875 B/op | 52 allocs/op |
+| BenchmarkImageURL-10 | 15412327 | 77.79 ns/op | 38 B/op | 3 allocs/op |
+| BenchmarkImage-10 | 63 | 18696842 ns/op | 2457675 B/op | 307202 allocs/op |
+| BenchmarkImageJpeg-10 | 38 | 29468572 ns/op | 2982467 B/op | 307217 allocs/op |
+| BenchmarkImagePng-10 | 16 | 68482049 ns/op | 5899021 B/op | 307270 allocs/op |
+| BenchmarkDomainName-10 | 3059372 | 392.7 ns/op | 95 B/op | 5 allocs/op |
+| BenchmarkDomainSuffix-10 | 23718696 | 50.49 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkURL-10 | 1288100 | 944.0 ns/op | 277 B/op | 10 allocs/op |
+| BenchmarkHTTPMethod-10 | 21987484 | 54.48 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkIPv4Address-10 | 6136962 | 195.2 ns/op | 16 B/op | 1 allocs/op |
+| BenchmarkIPv6Address-10 | 2601337 | 461.5 ns/op | 111 B/op | 8 allocs/op |
+| BenchmarkMacAddress-10 | 3300115 | 363.0 ns/op | 24 B/op | 1 allocs/op |
+| BenchmarkHTTPStatusCode-10 | 17352846 | 69.17 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkHTTPStatusCodeSimple-10 | 18258100 | 65.57 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkLogLevel-10 | 23441868 | 51.08 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkUserAgent-10 | 1902708 | 630.4 ns/op | 298 B/op | 5 allocs/op |
+| BenchmarkChromeUserAgent-10 | 2524466 | 473.4 ns/op | 184 B/op | 5 allocs/op |
+| BenchmarkFirefoxUserAgent-10 | 1556302 | 771.4 ns/op | 362 B/op | 6 allocs/op |
+| BenchmarkSafariUserAgent-10 | 1543339 | 777.2 ns/op | 551 B/op | 7 allocs/op |
+| BenchmarkOperaUserAgent-10 | 2315252 | 517.9 ns/op | 212 B/op | 5 allocs/op |
+| BenchmarkJSONLookup100-10 | 938 | 1287307 ns/op | 816308 B/op | 12135 allocs/op |
+| BenchmarkLanguage-10 | 25106659 | 47.70 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkLanguageAbbreviation-10 | 26723254 | 44.88 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkLanguageBCP-10 | 23676246 | 50.56 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkProgrammingLanguage-10 | 22303432 | 53.67 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkLoremIpsumWord-10 | 25471666 | 47.06 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkLoremIpsumSentence-10 | 1400270 | 857.5 ns/op | 219 B/op | 2 allocs/op |
+| BenchmarkLoremIpsumParagraph-10 | 70117 | 17029 ns/op | 8479 B/op | 40 allocs/op |
+| BenchmarkMinecraftOre-10 | 16607262 | 72.11 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftWood-10 | 16687941 | 71.81 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftArmorTier-10 | 16707594 | 71.67 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftArmorPart-10 | 16674888 | 71.96 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftWeapon-10 | 16790241 | 71.49 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftTool-10 | 16686007 | 71.83 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftDye-10 | 16578057 | 72.21 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftFood-10 | 15760260 | 76.06 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftAnimal-10 | 16580454 | 72.37 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftVillagerJob-10 | 16582592 | 72.21 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftVillagerStation-10 | 16320229 | 73.41 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftVillagerLevel-10 | 16137780 | 74.37 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftMobPassive-10 | 16823058 | 71.14 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftMobNeutral-10 | 16455928 | 72.87 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftMobHostile-10 | 15813878 | 75.74 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftMobBoss-10 | 15630010 | 76.57 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftBiome-10 | 16159348 | 74.21 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinecraftWeather-10 | 15548354 | 77.18 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkBool-10 | 74414372 | 16.16 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkUUID-10 | 4171688 | 287.7 ns/op | 48 B/op | 1 allocs/op |
+| BenchmarkShuffleAnySlice-10 | 3161480 | 379.2 ns/op | 24 B/op | 1 allocs/op |
+| BenchmarkFlipACoin-10 | 74035035 | 16.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMovie-10 | 8781188 | 135.8 ns/op | 32 B/op | 1 allocs/op |
+| BenchmarkMovieName-10 | 24128484 | 49.60 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMovieGenre-10 | 23041234 | 52.07 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNumber-10 | 73899970 | 16.14 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkUint8-10 | 72125496 | 16.55 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkUint16-10 | 72266845 | 16.56 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkUint32-10 | 72048993 | 16.55 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkUint64-10 | 72268842 | 16.55 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkUintRange-10 | 74468632 | 16.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkInt8-10 | 73880443 | 16.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkInt16-10 | 74023618 | 16.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkInt32-10 | 72283168 | 16.55 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkInt64-10 | 72318379 | 16.55 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkIntRange-10 | 74263170 | 16.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkFloat32-10 | 73899206 | 16.16 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkFloat32Range-10 | 73803760 | 16.16 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkFloat64-10 | 72352354 | 16.58 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkFloat64Range-10 | 72968102 | 16.41 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkShuffleInts-10 | 9118050 | 131.5 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkRandomInt-10 | 72387454 | 16.57 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkRandomUint-10 | 72164350 | 16.55 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkHexUint8-10 | 27118056 | 44.24 ns/op | 8 B/op | 2 allocs/op |
+| BenchmarkHexUint16-10 | 14899891 | 80.26 ns/op | 16 B/op | 2 allocs/op |
+| BenchmarkHexUint32-10 | 7935871 | 151.7 ns/op | 32 B/op | 2 allocs/op |
+| BenchmarkHexUint64-10 | 4170579 | 287.5 ns/op | 48 B/op | 2 allocs/op |
+| BenchmarkHexUint128-10 | 2147535 | 558.7 ns/op | 96 B/op | 2 allocs/op |
+| BenchmarkHexUint256-10 | 1000000 | 1104 ns/op | 160 B/op | 2 allocs/op |
+| BenchmarkCurrency-10 | 15053848 | 79.94 ns/op | 32 B/op | 1 allocs/op |
+| BenchmarkCurrencyShort-10 | 26722684 | 44.80 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCurrencyLong-10 | 25114737 | 47.62 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPrice-10 | 73138586 | 16.33 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCreditCard-10 | 1000000 | 1138 ns/op | 264 B/op | 15 allocs/op |
+| BenchmarkCreditCardType-10 | 31956361 | 37.34 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkCreditCardNumber-10 | 1535527 | 781.5 ns/op | 183 B/op | 10 allocs/op |
+| BenchmarkCreditCardExp-10 | 11157142 | 106.8 ns/op | 5 B/op | 1 allocs/op |
+| BenchmarkCreditCardCvv-10 | 20467788 | 58.54 ns/op | 3 B/op | 1 allocs/op |
+| BenchmarkAchRouting-10 | 7131913 | 159.7 ns/op | 16 B/op | 1 allocs/op |
+| BenchmarkAchAccount-10 | 5750278 | 208.4 ns/op | 16 B/op | 1 allocs/op |
+| BenchmarkBitcoinAddress-10 | 527527 | 2256 ns/op | 715 B/op | 37 allocs/op |
+| BenchmarkBitcoinPrivateKey-10 | 1312020 | 915.3 ns/op | 184 B/op | 5 allocs/op |
+| BenchmarkName-10 | 7987867 | 149.9 ns/op | 16 B/op | 1 allocs/op |
+| BenchmarkFirstName-10 | 23559168 | 50.87 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMiddleName-10 | 17695417 | 67.89 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkLastName-10 | 20915487 | 57.27 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNamePrefix-10 | 26101070 | 46.02 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNameSuffix-10 | 22054024 | 54.36 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkSSN-10 | 32379632 | 36.71 ns/op | 16 B/op | 1 allocs/op |
+| BenchmarkGender-10 | 74214370 | 16.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkHobby-10 | 17543538 | 68.35 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPerson-10 | 328150 | 3576 ns/op | 836 B/op | 32 allocs/op |
+| BenchmarkContact-10 | 1857553 | 643.7 ns/op | 136 B/op | 6 allocs/op |
+| BenchmarkPhone-10 | 6788635 | 176.7 ns/op | 16 B/op | 1 allocs/op |
+| BenchmarkPhoneFormatted-10 | 4711425 | 253.7 ns/op | 16 B/op | 1 allocs/op |
+| BenchmarkEmail-10 | 2846696 | 420.6 ns/op | 88 B/op | 4 allocs/op |
+| BenchmarkTeams-10 | 1547748 | 774.7 ns/op | 672 B/op | 10 allocs/op |
+| BenchmarkProduct-10 | 207730 | 5835 ns/op | 1068 B/op | 31 allocs/op |
+| BenchmarkProductName-10 | 2246737 | 534.4 ns/op | 103 B/op | 5 allocs/op |
+| BenchmarkProductDescription-10 | 356503 | 3328 ns/op | 549 B/op | 8 allocs/op |
+| BenchmarkProductCategory-10 | 23509492 | 50.94 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkProductFeature-10 | 19975862 | 60.10 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkProductMaterial-10 | 16895538 | 71.03 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkProductUPC-10 | 1367638 | 875.6 ns/op | 96 B/op | 11 allocs/op |
+| BenchmarkSchool-10 | 5458804 | 219.7 ns/op | 34 B/op | 1 allocs/op |
+| BenchmarkLetter-10 | 71643219 | 16.66 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkLetterN-10 | 5059563 | 236.5 ns/op | 64 B/op | 2 allocs/op |
+| BenchmarkVowel-10 | 58373920 | 20.67 ns/op | 4 B/op | 1 allocs/op |
+| BenchmarkDigit-10 | 71860232 | 16.71 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkDigitN-10 | 5075998 | 236.8 ns/op | 64 B/op | 2 allocs/op |
+| BenchmarkNumerify-10 | 6797595 | 176.1 ns/op | 16 B/op | 1 allocs/op |
+| BenchmarkLexify-10 | 11170232 | 107.4 ns/op | 8 B/op | 1 allocs/op |
+| BenchmarkShuffleStrings-10 | 9975268 | 120.1 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkRandomString-10 | 73696868 | 16.30 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkTemplate-10 | 2539 | 480370 ns/op | 283084 B/op | 4681 allocs/op |
+| BenchmarkDate-10 | 10351170 | 115.7 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPastDate-10 | 18027559 | 66.44 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkFutureDate-10 | 18718327 | 64.05 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkDateRange-10 | 8422170 | 142.5 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMonth-10 | 74189328 | 16.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMonthString-10 | 73959368 | 16.16 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkWeekDay-10 | 72201440 | 16.27 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkDay-10 | 74319124 | 16.14 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkYear-10 | 74319318 | 16.14 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkHour-10 | 74070644 | 16.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkMinute-10 | 73946456 | 16.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkSecond-10 | 74276002 | 16.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNanoSecond-10 | 73999466 | 16.13 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkTimeZone-10 | 19861794 | 60.31 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkTimeZoneFull-10 | 16748313 | 71.57 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkTimeZoneAbv-10 | 21469321 | 55.82 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkTimeZoneOffset-10 | 15023388 | 79.76 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkTimeZoneRegion-10 | 16213138 | 73.94 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkWeighted-10 | 29409751 | 40.55 ns/op | 16 B/op | 1 allocs/op |
+| BenchmarkAdjective-10 | 7012708 | 171.0 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdjectiveDescriptive-10 | 16624210 | 72.11 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdjectiveQuantitative-10 | 16431452 | 72.88 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdjectiveProper-10 | 17418051 | 68.84 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdjectiveDemonstrative-10 | 16586106 | 72.33 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdjectivePossessive-10 | 16352059 | 73.30 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdjectiveInterrogative-10 | 16728264 | 71.58 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdjectiveIndefinite-10 | 16374865 | 73.25 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdverb-10 | 7213459 | 166.2 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdverbManner-10 | 16105462 | 74.82 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdverbDegree-10 | 17215963 | 69.67 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdverbPlace-10 | 17027968 | 70.44 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdverbTimeDefinite-10 | 16807536 | 71.33 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdverbTimeIndefinite-10 | 16834258 | 71.29 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdverbFrequencyDefinite-10 | 16643116 | 72.10 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkAdverbFrequencyIndefinite-10 | 16712266 | 71.80 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkComment-10 | 1000000 | 1124 ns/op | 258 B/op | 6 allocs/op |
+| BenchmarkConnective-10 | 7623532 | 157.5 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkConnectiveTime-10 | 14703411 | 81.57 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkConnectiveComparative-10 | 16663310 | 72.02 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkConnectiveComplaint-10 | 16605826 | 72.29 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkConnectiveListing-10 | 16070548 | 74.58 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkConnectiveCasual-10 | 16650988 | 72.01 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkConnectiveExamplify-10 | 16406899 | 73.16 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkWord-10 | 8424476 | 142.2 ns/op | 3 B/op | 0 allocs/op |
+| BenchmarkSentenceSimple-10 | 707913 | 1715 ns/op | 590 B/op | 11 allocs/op |
+| BenchmarkInterjection-10 | 16653078 | 71.87 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNoun-10 | 6856959 | 175.0 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNounCommon-10 | 17568795 | 67.45 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNounConcrete-10 | 17735508 | 67.63 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNounAbstract-10 | 17774474 | 67.42 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNounCollectivePeople-10 | 16644973 | 72.10 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNounCollectiveAnimal-10 | 16826046 | 71.30 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNounCollectiveThing-10 | 16829851 | 71.31 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNounCountable-10 | 17706612 | 69.16 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNounUncountable-10 | 17657629 | 67.97 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkNounProper-10 | 11185551 | 106.9 ns/op | 7 B/op | 0 allocs/op |
+| BenchmarkNounDeterminer-10 | 17901252 | 67.10 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPhrase-10 | 20295181 | 59.11 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPhraseNoun-10 | 2975310 | 402.1 ns/op | 104 B/op | 2 allocs/op |
+| BenchmarkPhraseVerb-10 | 1414914 | 848.5 ns/op | 232 B/op | 6 allocs/op |
+| BenchmarkPhraseAdverb-10 | 7854709 | 151.7 ns/op | 9 B/op | 0 allocs/op |
+| BenchmarkPhrasePreposition-10 | 2333119 | 516.6 ns/op | 123 B/op | 3 allocs/op |
+| BenchmarkPreposition-10 | 9345999 | 128.3 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPrepositionSimple-10 | 16774008 | 71.50 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPrepositionDouble-10 | 16645617 | 72.09 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPrepositionCompound-10 | 16644290 | 72.30 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPronoun-10 | 6586246 | 182.0 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPronounPersonal-10 | 17675358 | 67.87 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPronounObject-10 | 16869451 | 71.12 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPronounPossessive-10 | 16814512 | 71.37 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPronounReflective-10 | 16223980 | 74.03 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPronounIndefinite-10 | 16787139 | 71.50 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPronounDemonstrative-10 | 16522154 | 72.55 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPronounInterrogative-10 | 16784683 | 71.50 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkPronounRelative-10 | 17615938 | 68.12 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkSentence-10 | 755766 | 1599 ns/op | 219 B/op | 3 allocs/op |
+| BenchmarkParagraph-10 | 40198 | 29978 ns/op | 6686 B/op | 53 allocs/op |
+| BenchmarkQuestion-10 | 1714515 | 700.9 ns/op | 242 B/op | 3 allocs/op |
+| BenchmarkQuote-10 | 1477675 | 810.9 ns/op | 261 B/op | 3 allocs/op |
+| BenchmarkVerb-10 | 9484125 | 126.5 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkVerbAction-10 | 17250270 | 69.67 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkVerbTransitive-10 | 17820943 | 67.54 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkVerbIntransitive-10 | 16775746 | 71.37 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkVerbLinking-10 | 17926422 | 66.91 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkVerbHelping-10 | 17875374 | 66.91 ns/op | 0 B/op | 0 allocs/op |
+| BenchmarkXMLLookup100-10 | 908 | 1314152 ns/op | 862571 B/op | 11370 allocs/op |
\ No newline at end of file
diff --git a/README.md b/README.md
index b42992d1..1f27284d 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
![alt text](https://raw.githubusercontent.com/brianvoe/gofakeit/master/logo.png)
-# Gofakeit [![Go Report Card](https://goreportcard.com/badge/github.com/brianvoe/gofakeit)](https://goreportcard.com/report/github.com/brianvoe/gofakeit) ![Test](https://github.com/brianvoe/gofakeit/workflows/Test/badge.svg?branch=master) [![GoDoc](https://godoc.org/github.com/brianvoe/gofakeit/v6?status.svg)](https://godoc.org/github.com/brianvoe/gofakeit/v6) [![license](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/brianvoe/gofakeit/master/LICENSE.txt)
+# Gofakeit [![Go Report Card](https://goreportcard.com/badge/github.com/brianvoe/gofakeit)](https://goreportcard.com/report/github.com/brianvoe/gofakeit) ![Test](https://github.com/brianvoe/gofakeit/workflows/Test/badge.svg?branch=master) [![GoDoc](https://godoc.org/github.com/brianvoe/gofakeit/v7?status.svg)](https://godoc.org/github.com/brianvoe/gofakeit/v7) [![license](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/brianvoe/gofakeit/master/LICENSE.txt)
Random data generator written in go
@@ -33,13 +33,13 @@ Thank you to all our Gofakeit contributors!
## Installation
```go
-go get github.com/brianvoe/gofakeit/v6
+go get github.com/brianvoe/gofakeit/v7
```
## Simple Usage
```go
-import "github.com/brianvoe/gofakeit/v6"
+import "github.com/brianvoe/gofakeit/v7"
gofakeit.Name() // Markus Moen
gofakeit.Email() // alaynawuckert@kozey.biz
@@ -65,7 +65,7 @@ If you need a reproducible outcome you can set it via the Seed function call. Ev
this repo sets it for testing purposes.
```go
-import "github.com/brianvoe/gofakeit/v6"
+import "github.com/brianvoe/gofakeit/v7"
gofakeit.Seed(0) // If 0 will use crypto/rand to generate a number
@@ -76,25 +76,43 @@ gofakeit.Seed(8675309) // Set it to whatever number you want
## Random Sources
-Gofakeit has a few rand sources, by default it uses math.Rand and uses mutex locking to allow for safe goroutines.
+Gofakeit has a few rand sources, by default it uses math/rand/v2 PCG which is a pseudo random number generator and is thread locked.
-If you want to use a more performant source please use NewUnlocked. Be aware that it is not goroutine safe.
+If you want to see other potential sources you can see the sub package [Source](https://pkg.go.dev/github.com/brianvoe/gofakeit/v7/source) for more information.
```go
-import "github.com/brianvoe/gofakeit/v6"
+import (
+ "github.com/brianvoe/gofakeit/v7"
+ "github.com/brianvoe/gofakeit/v7/source"
+ "math/rand/v2"
+)
-// Uses math/rand(Pseudo) with mutex locking
+// Uses math/rand/v2(PCG Pseudo) with mutex locking
faker := gofakeit.New(0)
-// Uses math/rand(Pseudo) with NO mutext locking
-// More performant but not goroutine safe.
-faker := gofakeit.NewUnlocked(0)
+// NewFaker takes in a source and whether or not it should be thread safe
+faker := gofakeit.NewFaker(source rand.Source, threadSafe bool)
-// Uses crypto/rand(cryptographically secure) with mutext locking
-faker := gofakeit.NewCrypto()
+// PCG Pseudo
+faker := gofakeit.NewFaker(rand.NewPCG(11, 11), true)
-// Pass in your own random source
-faker := gofakeit.NewCustom()
+// ChaCha8
+faker := gofakeit.NewFaker(rand.NewChaCha8([32]byte{0, 1, 2, 3, 4, 5}), true)
+
+
+// Additional from Gofakeit sub package source
+
+// JSF(Jenkins Small Fast)
+faker := gofakeit.NewFaker(source.NewJSF(11), true)
+
+// SFC(Simple Fast Counter)
+faker := gofakeit.NewFaker(source.NewSFC(11), true)
+
+// Crypto - Uses crypto/rand
+faker := gofakeit.NewFaker(source.NewCrypto(), true)
+
+// Dumb - simple incrementing number
+faker := gofakeit.NewFaker(source.NewDumb(11), true)
```
## Global Rand Set
@@ -103,10 +121,13 @@ If you would like to use the simple function calls but need to use something lik
crypto/rand you can override the default global with the random source that you want.
```go
-import "github.com/brianvoe/gofakeit/v6"
+import (
+ "github.com/brianvoe/gofakeit/v7"
+ "math/rand/v2"
+)
-faker := gofakeit.NewCrypto()
-gofakeit.SetGlobalFaker(faker)
+faker := gofakeit.New(0)
+gofakeit.GlobalFaker = faker
```
## Struct
@@ -117,7 +138,7 @@ as well as some non-basic like time.Time.
Struct fields can also use tags to more specifically generate data for that field type.
```go
-import "github.com/brianvoe/gofakeit/v6"
+import "github.com/brianvoe/gofakeit/v7"
// Create structs with random injected data
type Foo struct {
@@ -147,14 +168,14 @@ type Bar struct {
// Pass your struct as a pointer
var f Foo
-gofakeit.Struct(&f)
+err := gofakeit.Struct(&f)
fmt.Println(f.Str) // hrukpttuezptneuvunh
fmt.Println(f.Int) // -7825289004089916589
fmt.Println(*f.Pointer) // -343806609094473732
fmt.Println(f.Name) // fred
fmt.Println(f.Sentence) // Record river mind.
-fmt.Println(f.RandStr) // world
+fmt.Println(fStr) // world
fmt.Println(f.Number) // 4
fmt.Println(f.Regex) // cbdfc
fmt.Println(f.Map) // map[PxLIo:52 lxwnqhqc:846]
@@ -229,8 +250,8 @@ gofakeit.AddFuncLookup("friendname", gofakeit.Info{
Description: "Random friend name",
Example: "bill",
Output: "string",
- Generate: func(r *rand.Rand, m *gofakeit.MapParams, info *gofakeit.Info) (any, error) {
- return gofakeit.RandomString([]string{"bill", "bob", "sally"}), nil
+ Generate: func(f *Faker, m *gofakeit.MapParams, info *gofakeit.Info) (any, error) {
+ return f.RandomString([]string{"bill", "bob", "sally"}), nil
},
})
@@ -243,14 +264,14 @@ gofakeit.AddFuncLookup("jumbleword", gofakeit.Info{
Params: []gofakeit.Param{
{Field: "word", Type: "string", Description: "Word you want to jumble"},
},
- Generate: func(r *rand.Rand, m *gofakeit.MapParams, info *gofakeit.Info) (any, error) {
+ Generate: func(f *Faker, m *gofakeit.MapParams, info *gofakeit.Info) (any, error) {
word, err := info.GetString(m, "word")
if err != nil {
return nil, err
}
split := strings.Split(word, "")
- gofakeit.ShuffleStrings(split)
+ f.ShuffleStrings(split)
return strings.Join(split, ""), nil
},
})
@@ -301,7 +322,7 @@ Additional Available Functions
### Example Usages
```go
-import "github.com/brianvoe/gofakeit/v6"
+import "github.com/brianvoe/gofakeit/v7"
func main() {
// Accessing the Lines variable from within the template.
@@ -748,10 +769,14 @@ ProgrammingLanguageBest() string
```go
Number(min int, max int) int
+Int() int
+IntN(n int) int
Int8() int8
Int16() int16
Int32() int32
Int64() int64
+Uint() uint
+UintN(n uint) uint
Uint8() uint8
Uint16() uint16
Uint32() uint32
@@ -762,12 +787,7 @@ Float64() float64
Float64Range(min, max float64) float64
ShuffleInts(a []int)
RandomInt(i []int) int
-HexUint8() string
-HexUint16() string
-HexUint32() string
-HexUint64() string
-HexUint128() string
-HexUint256() string
+HexUint(bitsize int) string
```
### String
diff --git a/address.go b/address.go
index 3c8bc96f..f8e4e7b8 100644
--- a/address.go
+++ b/address.go
@@ -2,7 +2,6 @@ package gofakeit
import (
"errors"
- "math/rand"
"strings"
)
@@ -19,16 +18,16 @@ type AddressInfo struct {
}
// Address will generate a struct of address information
-func Address() *AddressInfo { return address(globalFaker.Rand) }
+func Address() *AddressInfo { return address(GlobalFaker) }
// Address will generate a struct of address information
-func (f *Faker) Address() *AddressInfo { return address(f.Rand) }
+func (f *Faker) Address() *AddressInfo { return address(f) }
-func address(r *rand.Rand) *AddressInfo {
- street := street(r)
- city := city(r)
- state := state(r)
- zip := zip(r)
+func address(f *Faker) *AddressInfo {
+ street := street(f)
+ city := city(f)
+ state := state(f)
+ zip := zip(f)
return &AddressInfo{
Address: street + ", " + city + ", " + state + " " + zip,
@@ -36,162 +35,162 @@ func address(r *rand.Rand) *AddressInfo {
City: city,
State: state,
Zip: zip,
- Country: country(r),
- Latitude: latitude(r),
- Longitude: longitude(r),
+ Country: country(f),
+ Latitude: latitude(f),
+ Longitude: longitude(f),
}
}
// Street will generate a random address street string
-func Street() string { return street(globalFaker.Rand) }
+func Street() string { return street(GlobalFaker) }
// Street will generate a random address street string
-func (f *Faker) Street() string { return street(f.Rand) }
+func (f *Faker) Street() string { return street(f) }
-func street(r *rand.Rand) string {
+func street(f *Faker) string {
var street = ""
- switch randInt := randIntRange(r, 1, 2); randInt {
+ switch randInt := randIntRange(f, 1, 2); randInt {
case 1:
- street = streetNumber(r) + " " + streetPrefix(r) + " " + streetName(r) + streetSuffix(r)
+ street = streetNumber(f) + " " + streetPrefix(f) + " " + streetName(f) + streetSuffix(f)
case 2:
- street = streetNumber(r) + " " + streetName(r) + streetSuffix(r)
+ street = streetNumber(f) + " " + streetName(f) + streetSuffix(f)
}
return street
}
// StreetNumber will generate a random address street number string
-func StreetNumber() string { return streetNumber(globalFaker.Rand) }
+func StreetNumber() string { return streetNumber(GlobalFaker) }
// StreetNumber will generate a random address street number string
-func (f *Faker) StreetNumber() string { return streetNumber(f.Rand) }
+func (f *Faker) StreetNumber() string { return streetNumber(f) }
-func streetNumber(r *rand.Rand) string {
- return strings.TrimLeft(replaceWithNumbers(r, getRandValue(r, []string{"address", "number"})), "0")
+func streetNumber(f *Faker) string {
+ return strings.TrimLeft(replaceWithNumbers(f, getRandValue(f, []string{"address", "number"})), "0")
}
// StreetPrefix will generate a random address street prefix string
-func StreetPrefix() string { return streetPrefix(globalFaker.Rand) }
+func StreetPrefix() string { return streetPrefix(GlobalFaker) }
// StreetPrefix will generate a random address street prefix string
-func (f *Faker) StreetPrefix() string { return streetPrefix(f.Rand) }
+func (f *Faker) StreetPrefix() string { return streetPrefix(f) }
-func streetPrefix(r *rand.Rand) string { return getRandValue(r, []string{"address", "street_prefix"}) }
+func streetPrefix(f *Faker) string { return getRandValue(f, []string{"address", "street_prefix"}) }
// StreetName will generate a random address street name string
-func StreetName() string { return streetName(globalFaker.Rand) }
+func StreetName() string { return streetName(GlobalFaker) }
// StreetName will generate a random address street name string
-func (f *Faker) StreetName() string { return streetName(f.Rand) }
+func (f *Faker) StreetName() string { return streetName(f) }
-func streetName(r *rand.Rand) string { return getRandValue(r, []string{"address", "street_name"}) }
+func streetName(f *Faker) string { return getRandValue(f, []string{"address", "street_name"}) }
// StreetSuffix will generate a random address street suffix string
-func StreetSuffix() string { return streetSuffix(globalFaker.Rand) }
+func StreetSuffix() string { return streetSuffix(GlobalFaker) }
// StreetSuffix will generate a random address street suffix string
-func (f *Faker) StreetSuffix() string { return streetSuffix(f.Rand) }
+func (f *Faker) StreetSuffix() string { return streetSuffix(f) }
-func streetSuffix(r *rand.Rand) string { return getRandValue(r, []string{"address", "street_suffix"}) }
+func streetSuffix(f *Faker) string { return getRandValue(f, []string{"address", "street_suffix"}) }
// City will generate a random city string
-func City() string { return city(globalFaker.Rand) }
+func City() string { return city(GlobalFaker) }
// City will generate a random city string
-func (f *Faker) City() string { return city(f.Rand) }
+func (f *Faker) City() string { return city(f) }
-func city(r *rand.Rand) string { return getRandValue(r, []string{"address", "city"}) }
+func city(f *Faker) string { return getRandValue(f, []string{"address", "city"}) }
// State will generate a random state string
-func State() string { return state(globalFaker.Rand) }
+func State() string { return state(GlobalFaker) }
// State will generate a random state string
-func (f *Faker) State() string { return state(f.Rand) }
+func (f *Faker) State() string { return state(f) }
-func state(r *rand.Rand) string { return getRandValue(r, []string{"address", "state"}) }
+func state(f *Faker) string { return getRandValue(f, []string{"address", "state"}) }
// StateAbr will generate a random abbreviated state string
-func StateAbr() string { return stateAbr(globalFaker.Rand) }
+func StateAbr() string { return stateAbr(GlobalFaker) }
// StateAbr will generate a random abbreviated state string
-func (f *Faker) StateAbr() string { return stateAbr(f.Rand) }
+func (f *Faker) StateAbr() string { return stateAbr(f) }
-func stateAbr(r *rand.Rand) string { return getRandValue(r, []string{"address", "state_abr"}) }
+func stateAbr(f *Faker) string { return getRandValue(f, []string{"address", "state_abr"}) }
// Zip will generate a random Zip code string
-func Zip() string { return zip(globalFaker.Rand) }
+func Zip() string { return zip(GlobalFaker) }
// Zip will generate a random Zip code string
-func (f *Faker) Zip() string { return zip(f.Rand) }
+func (f *Faker) Zip() string { return zip(f) }
-func zip(r *rand.Rand) string {
- return replaceWithNumbers(r, getRandValue(r, []string{"address", "zip"}))
+func zip(f *Faker) string {
+ return replaceWithNumbers(f, getRandValue(f, []string{"address", "zip"}))
}
// Country will generate a random country string
-func Country() string { return country(globalFaker.Rand) }
+func Country() string { return country(GlobalFaker) }
// Country will generate a random country string
-func (f *Faker) Country() string { return country(f.Rand) }
+func (f *Faker) Country() string { return country(f) }
-func country(r *rand.Rand) string { return getRandValue(r, []string{"address", "country"}) }
+func country(f *Faker) string { return getRandValue(f, []string{"address", "country"}) }
// CountryAbr will generate a random abbreviated country string
-func CountryAbr() string { return countryAbr(globalFaker.Rand) }
+func CountryAbr() string { return countryAbr(GlobalFaker) }
// CountryAbr will generate a random abbreviated country string
-func (f *Faker) CountryAbr() string { return countryAbr(f.Rand) }
+func (f *Faker) CountryAbr() string { return countryAbr(f) }
-func countryAbr(r *rand.Rand) string { return getRandValue(r, []string{"address", "country_abr"}) }
+func countryAbr(f *Faker) string { return getRandValue(f, []string{"address", "country_abr"}) }
// Latitude will generate a random latitude float64
-func Latitude() float64 { return latitude(globalFaker.Rand) }
+func Latitude() float64 { return latitude(GlobalFaker) }
// Latitude will generate a random latitude float64
-func (f *Faker) Latitude() float64 { return latitude(f.Rand) }
+func (f *Faker) Latitude() float64 { return latitude(f) }
-func latitude(r *rand.Rand) float64 { return toFixed((r.Float64()*180)-90, 6) }
+func latitude(f *Faker) float64 { return toFixed((f.Float64()*180)-90, 6) }
// LatitudeInRange will generate a random latitude within the input range
func LatitudeInRange(min, max float64) (float64, error) {
- return latitudeInRange(globalFaker.Rand, min, max)
+ return latitudeInRange(GlobalFaker, min, max)
}
// LatitudeInRange will generate a random latitude within the input range
func (f *Faker) LatitudeInRange(min, max float64) (float64, error) {
- return latitudeInRange(f.Rand, min, max)
+ return latitudeInRange(f, min, max)
}
-func latitudeInRange(r *rand.Rand, min, max float64) (float64, error) {
+func latitudeInRange(f *Faker, min, max float64) (float64, error) {
if min > max || min < -90 || min > 90 || max < -90 || max > 90 {
return 0, errors.New("invalid min or max range, must be valid floats and between -90 and 90")
}
- return toFixed(float64Range(r, min, max), 6), nil
+ return toFixed(float64Range(f, min, max), 6), nil
}
// Longitude will generate a random longitude float64
-func Longitude() float64 { return longitude(globalFaker.Rand) }
+func Longitude() float64 { return longitude(GlobalFaker) }
// Longitude will generate a random longitude float64
-func (f *Faker) Longitude() float64 { return longitude(f.Rand) }
+func (f *Faker) Longitude() float64 { return longitude(f) }
-func longitude(r *rand.Rand) float64 { return toFixed((r.Float64()*360)-180, 6) }
+func longitude(f *Faker) float64 { return toFixed((f.Float64()*360)-180, 6) }
// LongitudeInRange will generate a random longitude within the input range
func LongitudeInRange(min, max float64) (float64, error) {
- return longitudeInRange(globalFaker.Rand, min, max)
+ return longitudeInRange(GlobalFaker, min, max)
}
// LongitudeInRange will generate a random longitude within the input range
func (f *Faker) LongitudeInRange(min, max float64) (float64, error) {
- return longitudeInRange(f.Rand, min, max)
+ return longitudeInRange(f, min, max)
}
-func longitudeInRange(r *rand.Rand, min, max float64) (float64, error) {
+func longitudeInRange(f *Faker, min, max float64) (float64, error) {
if min > max || min < -180 || min > 180 || max < -180 || max > 180 {
return 0, errors.New("invalid min or max range, must be valid floats and between -180 and 180")
}
- return toFixed(float64Range(r, min, max), 6), nil
+ return toFixed(float64Range(f, min, max), 6), nil
}
func addAddressLookup() {
@@ -211,8 +210,8 @@ func addAddressLookup() {
}`,
Output: "map[string]any",
ContentType: "application/json",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return address(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return address(f), nil
},
})
@@ -222,8 +221,8 @@ func addAddressLookup() {
Description: "Part of a country with significant population, often a central hub for culture and commerce",
Example: "Marcelside",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return city(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return city(f), nil
},
})
@@ -233,8 +232,8 @@ func addAddressLookup() {
Description: "Nation with its own government and defined territory",
Example: "United States of America",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return country(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return country(f), nil
},
})
@@ -244,8 +243,8 @@ func addAddressLookup() {
Description: "Shortened 2-letter form of a country's name",
Example: "US",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return countryAbr(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return countryAbr(f), nil
},
})
@@ -255,8 +254,8 @@ func addAddressLookup() {
Description: "Governmental division within a country, often having its own laws and government",
Example: "Illinois",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return state(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return state(f), nil
},
})
@@ -266,8 +265,8 @@ func addAddressLookup() {
Description: "Shortened 2-letter form of a country's state",
Example: "IL",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return stateAbr(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return stateAbr(f), nil
},
})
@@ -277,8 +276,8 @@ func addAddressLookup() {
Description: "Public road in a city or town, typically with houses and buildings on each side",
Example: "364 East Rapidsborough",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return street(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return street(f), nil
},
})
@@ -288,8 +287,8 @@ func addAddressLookup() {
Description: "Name given to a specific road or street",
Example: "View",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return streetName(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return streetName(f), nil
},
})
@@ -299,8 +298,8 @@ func addAddressLookup() {
Description: "Numerical identifier assigned to a street",
Example: "13645",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return streetNumber(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return streetNumber(f), nil
},
})
@@ -310,8 +309,8 @@ func addAddressLookup() {
Description: "Directional or descriptive term preceding a street name, like 'East' or 'Main'",
Example: "Lake",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return streetPrefix(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return streetPrefix(f), nil
},
})
@@ -321,8 +320,8 @@ func addAddressLookup() {
Description: "Designation at the end of a street name indicating type, like 'Avenue' or 'Street'",
Example: "land",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return streetSuffix(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return streetSuffix(f), nil
},
})
@@ -332,8 +331,8 @@ func addAddressLookup() {
Description: "Numerical code for postal address sorting, specific to a geographic area",
Example: "13645",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return zip(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return zip(f), nil
},
})
@@ -343,8 +342,8 @@ func addAddressLookup() {
Description: "Geographic coordinate specifying north-south position on Earth's surface",
Example: "-73.534056",
Output: "float",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return latitude(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return latitude(f), nil
},
})
@@ -358,7 +357,7 @@ func addAddressLookup() {
{Field: "min", Display: "Min", Type: "float", Default: "0", Description: "Minimum range"},
{Field: "max", Display: "Max", Type: "float", Default: "90", Description: "Maximum range"},
},
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
min, err := info.GetFloat64(m, "min")
if err != nil {
return nil, err
@@ -369,7 +368,7 @@ func addAddressLookup() {
return nil, err
}
- rangeOut, err := latitudeInRange(r, min, max)
+ rangeOut, err := latitudeInRange(f, min, max)
if err != nil {
return nil, err
}
@@ -384,8 +383,8 @@ func addAddressLookup() {
Description: "Geographic coordinate indicating east-west position on Earth's surface",
Example: "-147.068112",
Output: "float",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return longitude(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return longitude(f), nil
},
})
@@ -399,7 +398,7 @@ func addAddressLookup() {
{Field: "min", Display: "Min", Type: "float", Default: "0", Description: "Minimum range"},
{Field: "max", Display: "Max", Type: "float", Default: "180", Description: "Maximum range"},
},
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
min, err := info.GetFloat64(m, "min")
if err != nil {
return nil, err
@@ -410,7 +409,7 @@ func addAddressLookup() {
return nil, err
}
- rangeOut, err := longitudeInRange(r, min, max)
+ rangeOut, err := longitudeInRange(f, min, max)
if err != nil {
return nil, err
}
diff --git a/address_test.go b/address_test.go
index ad5385d7..86f0a4c4 100644
--- a/address_test.go
+++ b/address_test.go
@@ -17,14 +17,14 @@ func ExampleAddress() {
fmt.Println(address.Latitude)
fmt.Println(address.Longitude)
- // Output: 364 Unionsville, Norfolk, Ohio 99536
- // 364 Unionsville
- // Norfolk
- // Ohio
- // 99536
- // Lesotho
- // 88.792592
- // 174.504681
+ // Output: 125 East Routemouth, North Las Vegas, South Dakota 17999
+ // 125 East Routemouth
+ // North Las Vegas
+ // South Dakota
+ // 17999
+ // Iran (Islamic Republic of)
+ // 83.558542
+ // -159.896615
}
func ExampleFaker_Address() {
@@ -39,242 +39,134 @@ func ExampleFaker_Address() {
fmt.Println(address.Latitude)
fmt.Println(address.Longitude)
- // Output: 364 Unionsville, Norfolk, Ohio 99536
- // 364 Unionsville
- // Norfolk
- // Ohio
- // 99536
- // Lesotho
- // 88.792592
- // 174.504681
+ // Output: 125 East Routemouth, North Las Vegas, South Dakota 17999
+ // 125 East Routemouth
+ // North Las Vegas
+ // South Dakota
+ // 17999
+ // Iran (Islamic Republic of)
+ // 83.558542
+ // -159.896615
}
func BenchmarkAddress(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Address()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Address()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Address()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Address()
+ }
}
func ExampleStreet() {
Seed(11)
fmt.Println(Street())
- // Output: 364 Unionsville
+ // Output: 125 East Routemouth
}
func ExampleFaker_Street() {
f := New(11)
fmt.Println(f.Street())
- // Output: 364 Unionsville
+ // Output: 125 East Routemouth
}
func BenchmarkStreet(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Street()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Street()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Street()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Street()
+ }
}
func ExampleStreetNumber() {
Seed(11)
fmt.Println(StreetNumber())
- // Output: 13645
+ // Output: 812
}
func ExampleFaker_StreetNumber() {
f := New(11)
fmt.Println(f.StreetNumber())
- // Output: 13645
+ // Output: 812
}
func BenchmarkStreetNumber(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- StreetNumber()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.StreetNumber()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.StreetNumber()
- }
- })
+ for i := 0; i < b.N; i++ {
+ StreetNumber()
+ }
}
func ExampleStreetPrefix() {
Seed(11)
fmt.Println(StreetPrefix())
- // Output: Lake
+ // Output: Port
}
func ExampleFaker_StreetPrefix() {
f := New(11)
fmt.Println(f.StreetPrefix())
- // Output: Lake
+ // Output: Port
}
func BenchmarkStreetPrefix(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- StreetPrefix()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.StreetPrefix()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.StreetPrefix()
- }
- })
+ for i := 0; i < b.N; i++ {
+ StreetPrefix()
+ }
}
func ExampleStreetName() {
Seed(11)
fmt.Println(StreetName())
- // Output: View
+ // Output: Turnpike
}
func ExampleFaker_StreetName() {
f := New(11)
fmt.Println(f.StreetName())
- // Output: View
+ // Output: Turnpike
}
func BenchmarkStreetName(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- StreetName()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.StreetName()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.StreetName()
- }
- })
+ for i := 0; i < b.N; i++ {
+ StreetName()
+ }
}
func ExampleStreetSuffix() {
Seed(11)
fmt.Println(StreetSuffix())
- // Output: land
+ // Output: side
}
func ExampleFaker_StreetSuffix() {
f := New(11)
fmt.Println(f.StreetSuffix())
- // Output: land
+ // Output: side
}
func BenchmarkStreetSuffix(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- StreetSuffix()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.StreetSuffix()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.StreetSuffix()
- }
- })
+ for i := 0; i < b.N; i++ {
+ StreetSuffix()
+ }
}
func ExampleCity() {
Seed(11)
fmt.Println(City())
- // Output: Plano
+ // Output: Reno
}
func ExampleFaker_City() {
f := New(11)
fmt.Println(f.City())
- // Output: Plano
+ // Output: Reno
}
func TestCity(t *testing.T) {
@@ -284,293 +176,149 @@ func TestCity(t *testing.T) {
}
func BenchmarkCity(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- City()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.City()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.City()
- }
- })
+ for i := 0; i < b.N; i++ {
+ City()
+ }
}
func ExampleState() {
Seed(11)
fmt.Println(State())
- // Output: Hawaii
+ // Output: Vermont
}
func ExampleFaker_State() {
f := New(11)
fmt.Println(f.State())
- // Output: Hawaii
+ // Output: Vermont
}
func BenchmarkState(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- State()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.State()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.State()
- }
- })
+ for i := 0; i < b.N; i++ {
+ State()
+ }
}
func ExampleStateAbr() {
Seed(11)
fmt.Println(StateAbr())
- // Output: CO
+ // Output: WV
}
func ExampleFaker_StateAbr() {
f := New(11)
fmt.Println(f.StateAbr())
- // Output: CO
+ // Output: WV
}
func BenchmarkStateAbr(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- StateAbr()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.StateAbr()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.StateAbr()
- }
- })
+ for i := 0; i < b.N; i++ {
+ StateAbr()
+ }
}
func ExampleZip() {
Seed(11)
fmt.Println(Zip())
- // Output: 13645
+ // Output: 81252
}
func ExampleFaker_Zip() {
f := New(11)
fmt.Println(f.Zip())
- // Output: 13645
+ // Output: 81252
}
func BenchmarkZip(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Zip()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Zip()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Zip()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Zip()
+ }
}
func ExampleCountry() {
Seed(11)
fmt.Println(Country())
- // Output: Cabo Verde
+ // Output: Tonga
}
func ExampleFaker_Country() {
f := New(11)
fmt.Println(f.Country())
- // Output: Cabo Verde
+ // Output: Tonga
}
func BenchmarkCountry(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Country()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Country()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Country()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Country()
+ }
}
func ExampleCountryAbr() {
Seed(11)
fmt.Println(CountryAbr())
- // Output: CV
+ // Output: TO
}
func ExampleFaker_CountryAbr() {
f := New(11)
fmt.Println(f.CountryAbr())
- // Output: CV
+ // Output: TO
}
func BenchmarkCountryAbr(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- CountryAbr()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.CountryAbr()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.CountryAbr()
- }
- })
+ for i := 0; i < b.N; i++ {
+ CountryAbr()
+ }
}
func ExampleLatitude() {
Seed(11)
fmt.Println(Latitude())
- // Output: -73.534057
+ // Output: 48.654167
}
func ExampleFaker_Latitude() {
f := New(11)
fmt.Println(f.Latitude())
- // Output: -73.534057
+ // Output: 48.654167
}
func BenchmarkLatitude(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Latitude()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Latitude()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Latitude()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Latitude()
+ }
}
func ExampleLongitude() {
Seed(11)
fmt.Println(Longitude())
- // Output: -147.068113
+ // Output: 97.308335
}
func ExampleFaker_Longitude() {
f := New(11)
fmt.Println(f.Longitude())
- // Output: -147.068113
+ // Output: 97.308335
}
func BenchmarkLongitude(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Longitude()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Longitude()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Longitude()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Longitude()
+ }
}
func TestLatitudeInRange(t *testing.T) {
@@ -600,7 +348,7 @@ func ExampleLatitudeInRange() {
lat, _ := LatitudeInRange(21, 42)
fmt.Println(lat)
- // Output: 22.921026
+ // Output: 37.176319
}
func ExampleFaker_LatitudeInRange() {
@@ -608,31 +356,13 @@ func ExampleFaker_LatitudeInRange() {
lat, _ := f.LatitudeInRange(21, 42)
fmt.Println(lat)
- // Output: 22.921026
+ // Output: 37.176319
}
func BenchmarkLatitudeInRange(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- LatitudeInRange(-90, 90)
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.LatitudeInRange(-90, 90)
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.LatitudeInRange(-90, 90)
- }
- })
+ for i := 0; i < b.N; i++ {
+ LatitudeInRange(-90, 90)
+ }
}
func TestLongitudeInRange(t *testing.T) {
@@ -662,7 +392,7 @@ func ExampleLongitudeInRange() {
long, _ := LongitudeInRange(-10, 10)
fmt.Println(long)
- // Output: -8.170451
+ // Output: 5.406018
}
func ExampleFaker_LongitudeInRange() {
@@ -670,29 +400,11 @@ func ExampleFaker_LongitudeInRange() {
long, _ := f.LongitudeInRange(-10, 10)
fmt.Println(long)
- // Output: -8.170451
+ // Output: 5.406018
}
func BenchmarkLongitudeInRange(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- LongitudeInRange(-180, 180)
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.LongitudeInRange(-180, 180)
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.LongitudeInRange(-180, 180)
- }
- })
+ for i := 0; i < b.N; i++ {
+ LongitudeInRange(-180, 180)
+ }
}
diff --git a/animal.go b/animal.go
index 56772ea9..b70438b6 100644
--- a/animal.go
+++ b/animal.go
@@ -1,103 +1,101 @@
package gofakeit
-import "math/rand"
-
// PetName will return a random fun pet name
func PetName() string {
- return petName(globalFaker.Rand)
+ return petName(GlobalFaker)
}
// PetName will return a random fun pet name
func (f *Faker) PetName() string {
- return petName(f.Rand)
+ return petName(f)
}
-func petName(r *rand.Rand) string {
- return getRandValue(r, []string{"animal", "petname"})
+func petName(f *Faker) string {
+ return getRandValue(f, []string{"animal", "petname"})
}
// Animal will return a random animal
func Animal() string {
- return animal(globalFaker.Rand)
+ return animal(GlobalFaker)
}
// Animal will return a random animal
func (f *Faker) Animal() string {
- return animal(f.Rand)
+ return animal(f)
}
-func animal(r *rand.Rand) string {
- return getRandValue(r, []string{"animal", "animal"})
+func animal(f *Faker) string {
+ return getRandValue(f, []string{"animal", "animal"})
}
// AnimalType will return a random animal type
func AnimalType() string {
- return animalType(globalFaker.Rand)
+ return animalType(GlobalFaker)
}
// AnimalType will return a random animal type
func (f *Faker) AnimalType() string {
- return animalType(f.Rand)
+ return animalType(f)
}
-func animalType(r *rand.Rand) string {
- return getRandValue(r, []string{"animal", "type"})
+func animalType(f *Faker) string {
+ return getRandValue(f, []string{"animal", "type"})
}
// FarmAnimal will return a random animal that usually lives on a farm
func FarmAnimal() string {
- return farmAnimal(globalFaker.Rand)
+ return farmAnimal(GlobalFaker)
}
// FarmAnimal will return a random animal that usually lives on a farm
func (f *Faker) FarmAnimal() string {
- return farmAnimal(f.Rand)
+ return farmAnimal(f)
}
-func farmAnimal(r *rand.Rand) string {
- return getRandValue(r, []string{"animal", "farm"})
+func farmAnimal(f *Faker) string {
+ return getRandValue(f, []string{"animal", "farm"})
}
// Cat will return a random cat breed
func Cat() string {
- return cat(globalFaker.Rand)
+ return cat(GlobalFaker)
}
// Cat will return a random cat breed
func (f *Faker) Cat() string {
- return cat(f.Rand)
+ return cat(f)
}
-func cat(r *rand.Rand) string {
- return getRandValue(r, []string{"animal", "cat"})
+func cat(f *Faker) string {
+ return getRandValue(f, []string{"animal", "cat"})
}
// Dog will return a random dog breed
func Dog() string {
- return dog(globalFaker.Rand)
+ return dog(GlobalFaker)
}
// Dog will return a random dog breed
func (f *Faker) Dog() string {
- return dog(f.Rand)
+ return dog(f)
}
-func dog(r *rand.Rand) string {
- return getRandValue(r, []string{"animal", "dog"})
+func dog(f *Faker) string {
+ return getRandValue(f, []string{"animal", "dog"})
}
// Bird will return a random bird species
func Bird() string {
- return bird(globalFaker.Rand)
+ return bird(GlobalFaker)
}
// Bird will return a random bird species
func (f *Faker) Bird() string {
- return bird(f.Rand)
+ return bird(f)
}
-func bird(r *rand.Rand) string {
- return getRandValue(r, []string{"animal", "bird"})
+func bird(f *Faker) string {
+ return getRandValue(f, []string{"animal", "bird"})
}
func addAnimalLookup() {
@@ -107,8 +105,8 @@ func addAnimalLookup() {
Description: "Affectionate nickname given to a pet",
Example: "Ozzy Pawsborne",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return petName(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return petName(f), nil
},
})
@@ -118,8 +116,8 @@ func addAnimalLookup() {
Description: "Living creature with the ability to move, eat, and interact with its environment",
Example: "elk",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return animal(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return animal(f), nil
},
})
@@ -129,8 +127,8 @@ func addAnimalLookup() {
Description: "Type of animal, such as mammals, birds, reptiles, etc.",
Example: "amphibians",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return animalType(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return animalType(f), nil
},
})
@@ -140,8 +138,8 @@ func addAnimalLookup() {
Description: "Animal name commonly found on a farm",
Example: "Chicken",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return farmAnimal(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return farmAnimal(f), nil
},
})
@@ -151,8 +149,8 @@ func addAnimalLookup() {
Description: "Various breeds that define different cats",
Example: "Chausie",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return cat(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return cat(f), nil
},
})
@@ -162,8 +160,8 @@ func addAnimalLookup() {
Description: "Various breeds that define different dogs",
Example: "Norwich Terrier",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return dog(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return dog(f), nil
},
})
@@ -173,8 +171,8 @@ func addAnimalLookup() {
Description: "Distinct species of birds",
Example: "goose",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return bird(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return bird(f), nil
},
})
}
diff --git a/animal_test.go b/animal_test.go
index 580cfff5..26af90dc 100644
--- a/animal_test.go
+++ b/animal_test.go
@@ -9,152 +9,80 @@ func ExamplePetName() {
Seed(11)
fmt.Println(PetName())
- // Output: Ozzy Pawsborne
+ // Output: The Notorious D.O.G.
}
func ExampleFaker_PetName() {
f := New(11)
fmt.Println(f.PetName())
- // Output: Ozzy Pawsborne
+ // Output: The Notorious D.O.G.
}
func BenchmarkPetName(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- PetName()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.PetName()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.PetName()
- }
- })
+ for i := 0; i < b.N; i++ {
+ PetName()
+ }
}
func ExampleAnimal() {
Seed(11)
fmt.Println(Animal())
- // Output: elk
+ // Output: turtle
}
func ExampleFaker_Animal() {
f := New(11)
fmt.Println(f.Animal())
- // Output: elk
+ // Output: turtle
}
func BenchmarkAnimal(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Animal()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Animal()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Animal()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Animal()
+ }
}
func ExampleAnimalType() {
Seed(11)
fmt.Println(AnimalType())
- // Output: amphibians
+ // Output: reptiles
}
func ExampleFaker_AnimalType() {
f := New(11)
fmt.Println(f.AnimalType())
- // Output: amphibians
+ // Output: reptiles
}
func BenchmarkAnimalType(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- AnimalType()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.AnimalType()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.AnimalType()
- }
- })
+ for i := 0; i < b.N; i++ {
+ AnimalType()
+ }
}
func ExampleFarmAnimal() {
Seed(11)
fmt.Println(FarmAnimal())
- // Output: Chicken
+ // Output: Sheep
}
func ExampleFaker_FarmAnimal() {
f := New(11)
fmt.Println(f.FarmAnimal())
- // Output: Chicken
+ // Output: Sheep
}
func BenchmarkFarmAnimal(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- FarmAnimal()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.FarmAnimal()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.FarmAnimal()
- }
- })
+ for i := 0; i < b.N; i++ {
+ FarmAnimal()
+ }
}
func ExampleCat() {
@@ -172,101 +100,47 @@ func ExampleFaker_Cat() {
}
func BenchmarkCat(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Cat()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Cat()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Cat()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Cat()
+ }
}
func ExampleDog() {
Seed(11)
fmt.Println(Dog())
- // Output: Norwich Terrier
+ // Output: Rat Terrier
}
func ExampleFaker_Dog() {
f := New(11)
fmt.Println(f.Dog())
- // Output: Norwich Terrier
+ // Output: Rat Terrier
}
func BenchmarkDog(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Dog()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Dog()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Dog()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Dog()
+ }
}
func ExampleBird() {
Seed(11)
fmt.Println(Bird())
- // Output: goose
+ // Output: toucan
}
func ExampleFaker_Bird() {
f := New(11)
fmt.Println(f.Bird())
- // Output: goose
+ // Output: toucan
}
func BenchmarkBird(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Bird()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Bird()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Bird()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Bird()
+ }
}
diff --git a/app.go b/app.go
index 172c8179..9c66cd5c 100644
--- a/app.go
+++ b/app.go
@@ -2,28 +2,27 @@ package gofakeit
import (
"fmt"
- "math/rand"
)
// AppName will generate a random app name
func AppName() string {
- return appName(globalFaker.Rand)
+ return appName(GlobalFaker)
}
// AppName will generate a random app name
func (f *Faker) AppName() string {
- return appName(f.Rand)
+ return appName(f)
}
-func appName(r *rand.Rand) string {
+func appName(f *Faker) string {
name := ""
- switch number(r, 1, 3) {
+ switch number(f, 1, 3) {
case 1:
- name = noun(r) + verb(r)
+ name = noun(f) + verb(f)
case 2:
- name = color(r) + noun(r)
+ name = color(f) + noun(f)
case 3:
- name = animal(r) + verb(r)
+ name = animal(f) + verb(f)
}
return title(name)
@@ -31,34 +30,34 @@ func appName(r *rand.Rand) string {
// AppVersion will generate a random app version
func AppVersion() string {
- return appVersion(globalFaker.Rand)
+ return appVersion(GlobalFaker)
}
// AppVersion will generate a random app version
func (f *Faker) AppVersion() string {
- return appVersion(f.Rand)
+ return appVersion(f)
}
-func appVersion(r *rand.Rand) string {
- return fmt.Sprintf("%d.%d.%d", number(r, 1, 5), number(r, 1, 20), number(r, 1, 20))
+func appVersion(f *Faker) string {
+ return fmt.Sprintf("%d.%d.%d", number(f, 1, 5), number(f, 1, 20), number(f, 1, 20))
}
// AppAuthor will generate a random company or person name
func AppAuthor() string {
- return appAuthor(globalFaker.Rand)
+ return appAuthor(GlobalFaker)
}
// AppAuthor will generate a random company or person name
func (f *Faker) AppAuthor() string {
- return appAuthor(f.Rand)
+ return appAuthor(f)
}
-func appAuthor(r *rand.Rand) string {
- if boolFunc(r) {
- return name(r)
+func appAuthor(f *Faker) string {
+ if boolFunc(f) {
+ return name(f)
}
- return company(r)
+ return company(f)
}
func addAppLookup() {
@@ -68,8 +67,8 @@ func addAppLookup() {
Description: "Software program designed for a specific purpose or task on a computer or mobile device",
Example: "Parkrespond",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return appName(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return appName(f), nil
},
})
@@ -79,8 +78,8 @@ func addAppLookup() {
Description: "Particular release of an application in Semantic Versioning format",
Example: "1.12.14",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return appVersion(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return appVersion(f), nil
},
})
@@ -90,8 +89,8 @@ func addAppLookup() {
Description: "Person or group creating and developing an application",
Example: "Qado Energy, Inc.",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return appAuthor(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return appAuthor(f), nil
},
})
}
diff --git a/app_test.go b/app_test.go
index 990757cf..6bf4296f 100644
--- a/app_test.go
+++ b/app_test.go
@@ -9,14 +9,14 @@ func ExampleAppName() {
Seed(11)
fmt.Println(AppName())
- // Output: Oxbeing
+ // Output: Swanthink
}
func ExampleFaker_AppName() {
f := New(11)
fmt.Println(f.AppName())
- // Output: Oxbeing
+ // Output: Swanthink
}
func TestAppName(t *testing.T) {
@@ -29,79 +29,43 @@ func TestAppName(t *testing.T) {
}
func BenchmarkAppName(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- AppName()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.AppName()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.AppName()
- }
- })
+ for i := 0; i < b.N; i++ {
+ AppName()
+ }
}
func ExampleAppVersion() {
Seed(11)
fmt.Println(AppVersion())
- // Output: 1.17.20
+ // Output: 5.18.4
}
func ExampleFaker_AppVersion() {
f := New(11)
fmt.Println(f.AppVersion())
- // Output: 1.17.20
+ // Output: 5.18.4
}
func BenchmarkAppVersion(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- AppVersion()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.AppVersion()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.AppVersion()
- }
- })
+ for i := 0; i < b.N; i++ {
+ AppVersion()
+ }
}
func ExampleAppAuthor() {
Seed(11)
fmt.Println(AppAuthor())
- // Output: Marcel Pagac
+ // Output: StreetEasy
}
func ExampleFaker_AppAuthor() {
f := New(11)
fmt.Println(f.AppAuthor())
- // Output: Marcel Pagac
+ // Output: StreetEasy
}
func TestAuthor(t *testing.T) {
@@ -114,25 +78,7 @@ func TestAuthor(t *testing.T) {
}
func BenchmarkAppAuthor(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- AppAuthor()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.AppAuthor()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.AppAuthor()
- }
- })
+ for i := 0; i < b.N; i++ {
+ AppAuthor()
+ }
}
diff --git a/auth.go b/auth.go
index ae86e3d1..516a0187 100644
--- a/auth.go
+++ b/auth.go
@@ -1,34 +1,32 @@
package gofakeit
-import "math/rand"
-
// Username will generate a random username based upon picking a random lastname and random numbers at the end
func Username() string {
- return username(globalFaker.Rand)
+ return username(GlobalFaker)
}
// Username will generate a random username based upon picking a random lastname and random numbers at the end
func (f *Faker) Username() string {
- return username(f.Rand)
+ return username(f)
}
-func username(r *rand.Rand) string {
- return getRandValue(r, []string{"person", "last"}) + replaceWithNumbers(r, "####")
+func username(f *Faker) string {
+ return getRandValue(f, []string{"person", "last"}) + replaceWithNumbers(f, "####")
}
// Password will generate a random password.
// Minimum number length of 5 if less than.
func Password(lower bool, upper bool, numeric bool, special bool, space bool, num int) string {
- return password(globalFaker.Rand, lower, upper, numeric, special, space, num)
+ return password(GlobalFaker, lower, upper, numeric, special, space, num)
}
// Password will generate a random password.
// Minimum number length of 5 if less than.
func (f *Faker) Password(lower bool, upper bool, numeric bool, special bool, space bool, num int) string {
- return password(f.Rand, lower, upper, numeric, special, space, num)
+ return password(f, lower, upper, numeric, special, space, num)
}
-func password(r *rand.Rand, lower bool, upper bool, numeric bool, special bool, space bool, num int) string {
+func password(f *Faker, lower bool, upper bool, numeric bool, special bool, space bool, num int) string {
// Make sure the num minimum is at least 5
if num < 5 {
num = 5
@@ -69,34 +67,34 @@ func password(r *rand.Rand, lower bool, upper bool, numeric bool, special bool,
for i := 0; i <= num-1; i++ {
// Run weighted
- weight, _ := weighted(r, items, weights)
+ weight, _ := weighted(f, items, weights)
switch weight.(string) {
case "lower":
- b[i] = lowerStr[r.Int63()%int64(len(lowerStr))]
+ b[i] = lowerStr[f.Int64()%int64(len(lowerStr))]
case "upper":
- b[i] = upperStr[r.Int63()%int64(len(upperStr))]
+ b[i] = upperStr[f.Int64()%int64(len(upperStr))]
case "numeric":
- b[i] = numericStr[r.Int63()%int64(len(numericStr))]
+ b[i] = numericStr[f.Int64()%int64(len(numericStr))]
case "special":
- b[i] = specialSafeStr[r.Int63()%int64(len(specialSafeStr))]
+ b[i] = specialSafeStr[f.Int64()%int64(len(specialSafeStr))]
case "space":
- b[i] = spaceStr[r.Int63()%int64(len(spaceStr))]
+ b[i] = spaceStr[f.Int64()%int64(len(spaceStr))]
}
}
// Shuffle bytes
for i := range b {
- j := r.Intn(i + 1)
+ j := f.IntN(i + 1)
b[i], b[j] = b[j], b[i]
}
// Replace first or last character if it's a space, and other options are available
if b[0] == ' ' {
- b[0] = password(r, lower, upper, numeric, special, false, 1)[0]
+ b[0] = password(f, lower, upper, numeric, special, false, 1)[0]
}
if b[len(b)-1] == ' ' {
- b[len(b)-1] = password(r, lower, upper, numeric, special, false, 1)[0]
+ b[len(b)-1] = password(f, lower, upper, numeric, special, false, 1)[0]
}
return string(b)
@@ -109,8 +107,8 @@ func addAuthLookup() {
Description: "Unique identifier assigned to a user for accessing an account or system",
Example: "Daniel1364",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return username(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return username(f), nil
},
})
@@ -128,7 +126,7 @@ func addAuthLookup() {
{Field: "space", Display: "Space", Type: "bool", Default: "false", Description: "Whether or not to add spaces"},
{Field: "length", Display: "Length", Type: "int", Default: "12", Description: "Number of characters in password"},
},
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
lower, err := info.GetBool(m, "lower")
if err != nil {
return nil, err
@@ -159,7 +157,7 @@ func addAuthLookup() {
return nil, err
}
- return password(r, lower, upper, numeric, special, space, length), nil
+ return password(f, lower, upper, numeric, special, space, length), nil
},
})
}
diff --git a/auth_test.go b/auth_test.go
index ff0e144c..c1f91425 100644
--- a/auth_test.go
+++ b/auth_test.go
@@ -9,38 +9,20 @@ func ExampleUsername() {
Seed(11)
fmt.Println(Username())
- // Output: Daniel1364
+ // Output: Treutel8125
}
func ExampleFaker_Username() {
f := New(11)
fmt.Println(f.Username())
- // Output: Daniel1364
+ // Output: Treutel8125
}
func BenchmarkUsername(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Username()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Username()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Username()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Username()
+ }
}
func TestPassword(t *testing.T) {
@@ -76,12 +58,12 @@ func ExamplePassword() {
fmt.Println(Password(true, true, true, true, true, 32))
fmt.Println(Password(true, true, true, true, true, 4))
- // Output: vodnqxzsuptgehrzylximvylxzoywexw
- // ZSRQWJFJWCSTVGXKYKWMLIAFGFELFJRG
- // 61718615932495608398906260648432
- // !*$$??_!&!#.@@-!_!!$$-?_$&.@-&
- // d6UzSwXvJ81 7QPvlse@l ln VmvU5jd
- // UKTn2
+ // Output: cfelntbponnbbzrhswobuwlxajeeclrx
+ // KYEKNGUUNKUYSFBUFFTGDKUVCVYKPONP
+ // 43622637275953627791234759581343
+ // !?*-_-?#@!*?@?-&@!*!*?_!#$@@@**@
+ // .DTHJ&@oF#d.L5F65 N.-#U5xWX F0DI
+ // foZnB
}
func ExampleFaker_Password() {
@@ -93,34 +75,16 @@ func ExampleFaker_Password() {
fmt.Println(f.Password(true, true, true, true, true, 32))
fmt.Println(f.Password(true, true, true, true, true, 4))
- // Output: vodnqxzsuptgehrzylximvylxzoywexw
- // ZSRQWJFJWCSTVGXKYKWMLIAFGFELFJRG
- // 61718615932495608398906260648432
- // !*$$??_!&!#.@@-!_!!$$-?_$&.@-&
- // d6UzSwXvJ81 7QPvlse@l ln VmvU5jd
- // UKTn2
+ // Output: cfelntbponnbbzrhswobuwlxajeeclrx
+ // KYEKNGUUNKUYSFBUFFTGDKUVCVYKPONP
+ // 43622637275953627791234759581343
+ // !?*-_-?#@!*?@?-&@!*!*?_!#$@@@**@
+ // .DTHJ&@oF#d.L5F65 N.-#U5xWX F0DI
+ // foZnB
}
func BenchmarkPassword(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Password(true, true, true, true, true, 50)
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Password(true, true, true, true, true, 8)
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Password(true, true, true, true, true, 8)
- }
- })
+ for i := 0; i < b.N; i++ {
+ Password(true, true, true, true, true, 50)
+ }
}
diff --git a/beer.go b/beer.go
index 292ae680..a6bc493e 100644
--- a/beer.go
+++ b/beer.go
@@ -1,120 +1,119 @@
package gofakeit
import (
- "math/rand"
"strconv"
)
// BeerName will return a random beer name
func BeerName() string {
- return beerName(globalFaker.Rand)
+ return beerName(GlobalFaker)
}
// BeerName will return a random beer name
func (f *Faker) BeerName() string {
- return beerName(f.Rand)
+ return beerName(f)
}
-func beerName(r *rand.Rand) string {
- return getRandValue(r, []string{"beer", "name"})
+func beerName(f *Faker) string {
+ return getRandValue(f, []string{"beer", "name"})
}
// BeerStyle will return a random beer style
func BeerStyle() string {
- return beerStyle(globalFaker.Rand)
+ return beerStyle(GlobalFaker)
}
// BeerStyle will return a random beer style
func (f *Faker) BeerStyle() string {
- return beerStyle(f.Rand)
+ return beerStyle(f)
}
-func beerStyle(r *rand.Rand) string {
- return getRandValue(r, []string{"beer", "style"})
+func beerStyle(f *Faker) string {
+ return getRandValue(f, []string{"beer", "style"})
}
// BeerHop will return a random beer hop
func BeerHop() string {
- return beerHop(globalFaker.Rand)
+ return beerHop(GlobalFaker)
}
// BeerHop will return a random beer hop
func (f *Faker) BeerHop() string {
- return beerHop(f.Rand)
+ return beerHop(f)
}
-func beerHop(r *rand.Rand) string {
- return getRandValue(r, []string{"beer", "hop"})
+func beerHop(f *Faker) string {
+ return getRandValue(f, []string{"beer", "hop"})
}
// BeerYeast will return a random beer yeast
func BeerYeast() string {
- return beerYeast(globalFaker.Rand)
+ return beerYeast(GlobalFaker)
}
// BeerYeast will return a random beer yeast
func (f *Faker) BeerYeast() string {
- return beerYeast(f.Rand)
+ return beerYeast(f)
}
-func beerYeast(r *rand.Rand) string {
- return getRandValue(r, []string{"beer", "yeast"})
+func beerYeast(f *Faker) string {
+ return getRandValue(f, []string{"beer", "yeast"})
}
// BeerMalt will return a random beer malt
func BeerMalt() string {
- return beerMalt(globalFaker.Rand)
+ return beerMalt(GlobalFaker)
}
// BeerMalt will return a random beer malt
func (f *Faker) BeerMalt() string {
- return beerMalt(f.Rand)
+ return beerMalt(f)
}
-func beerMalt(r *rand.Rand) string {
- return getRandValue(r, []string{"beer", "malt"})
+func beerMalt(f *Faker) string {
+ return getRandValue(f, []string{"beer", "malt"})
}
// BeerAlcohol will return a random beer alcohol level between 2.0 and 10.0
func BeerAlcohol() string {
- return beerAlcohol(globalFaker.Rand)
+ return beerAlcohol(GlobalFaker)
}
// BeerAlcohol will return a random beer alcohol level between 2.0 and 10.0
func (f *Faker) BeerAlcohol() string {
- return beerAlcohol(f.Rand)
+ return beerAlcohol(f)
}
-func beerAlcohol(r *rand.Rand) string {
- return strconv.FormatFloat(float64Range(r, 2.0, 10.0), 'f', 1, 64) + "%"
+func beerAlcohol(f *Faker) string {
+ return strconv.FormatFloat(float64Range(f, 2.0, 10.0), 'f', 1, 64) + "%"
}
// BeerIbu will return a random beer ibu value between 10 and 100
func BeerIbu() string {
- return beerIbu(globalFaker.Rand)
+ return beerIbu(GlobalFaker)
}
// BeerIbu will return a random beer ibu value between 10 and 100
func (f *Faker) BeerIbu() string {
- return beerIbu(f.Rand)
+ return beerIbu(f)
}
-func beerIbu(r *rand.Rand) string {
- return strconv.Itoa(randIntRange(r, 10, 100)) + " IBU"
+func beerIbu(f *Faker) string {
+ return strconv.Itoa(randIntRange(f, 10, 100)) + " IBU"
}
// BeerBlg will return a random beer blg between 5.0 and 20.0
func BeerBlg() string {
- return beerBlg(globalFaker.Rand)
+ return beerBlg(GlobalFaker)
}
// BeerBlg will return a random beer blg between 5.0 and 20.0
func (f *Faker) BeerBlg() string {
- return beerBlg(f.Rand)
+ return beerBlg(f)
}
-func beerBlg(r *rand.Rand) string {
- return strconv.FormatFloat(float64Range(r, 5.0, 20.0), 'f', 1, 64) + "°Blg"
+func beerBlg(f *Faker) string {
+ return strconv.FormatFloat(float64Range(f, 5.0, 20.0), 'f', 1, 64) + "°Blg"
}
func addBeerLookup() {
@@ -124,8 +123,8 @@ func addBeerLookup() {
Description: "Specific brand or variety of beer",
Example: "Duvel",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return beerName(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return beerName(f), nil
},
})
@@ -135,8 +134,8 @@ func addBeerLookup() {
Description: "Distinct characteristics and flavors of beer",
Example: "European Amber Lager",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return beerStyle(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return beerStyle(f), nil
},
})
@@ -146,8 +145,8 @@ func addBeerLookup() {
Description: "The flower used in brewing to add flavor, aroma, and bitterness to beer",
Example: "Glacier",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return beerHop(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return beerHop(f), nil
},
})
@@ -157,8 +156,8 @@ func addBeerLookup() {
Description: "Microorganism used in brewing to ferment sugars, producing alcohol and carbonation in beer",
Example: "1388 - Belgian Strong Ale",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return beerYeast(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return beerYeast(f), nil
},
})
@@ -168,8 +167,8 @@ func addBeerLookup() {
Description: "Processed barley or other grains, provides sugars for fermentation and flavor to beer",
Example: "Munich",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return beerMalt(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return beerMalt(f), nil
},
})
@@ -179,8 +178,8 @@ func addBeerLookup() {
Description: "Measures the alcohol content in beer",
Example: "2.7%",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return beerAlcohol(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return beerAlcohol(f), nil
},
})
@@ -190,8 +189,8 @@ func addBeerLookup() {
Description: "Scale measuring bitterness of beer from hops",
Example: "29 IBU",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return beerIbu(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return beerIbu(f), nil
},
})
@@ -201,8 +200,8 @@ func addBeerLookup() {
Description: "Scale indicating the concentration of extract in worts",
Example: "6.4°Blg",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return beerBlg(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return beerBlg(f), nil
},
})
}
diff --git a/beer_test.go b/beer_test.go
index 6446dee0..e88105d8 100644
--- a/beer_test.go
+++ b/beer_test.go
@@ -9,152 +9,81 @@ func ExampleBeerName() {
Seed(11)
fmt.Println(BeerName())
- // Output: Duvel
+ // Output: Sierra Nevada Bigfoot Barleywine Style Ale
}
func ExampleFaker_BeerName() {
f := New(11)
fmt.Println(f.BeerName())
- // Output: Duvel
+ // Output: Sierra Nevada Bigfoot Barleywine Style Ale
}
func BenchmarkBeerName(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BeerName()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BeerName()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BeerName()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BeerName()
+ }
}
func ExampleBeerStyle() {
Seed(11)
fmt.Println(BeerStyle())
- // Output: European Amber Lager
+ // Output: Vegetable Beer
}
func ExampleFaker_BeerStyle() {
f := New(11)
fmt.Println(f.BeerStyle())
- // Output: European Amber Lager
+ // Output: Vegetable Beer
}
func BenchmarkBeerStyle(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BeerStyle()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BeerStyle()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BeerStyle()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BeerStyle()
+ }
}
func ExampleBeerHop() {
Seed(11)
fmt.Println(BeerHop())
- // Output: Glacier
+ // Output: TriplePearl
}
func ExampleFaker_BeerHop() {
f := New(11)
fmt.Println(f.BeerHop())
- // Output: Glacier
+ // Output: TriplePearl
}
func BenchmarkBeerHop(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BeerHop()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BeerHop()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BeerHop()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BeerHop()
+ }
}
func ExampleBeerYeast() {
Seed(11)
fmt.Println(BeerYeast())
- // Output: 1388 - Belgian Strong Ale
+ // Output: 2308 - Munich Lager
}
func ExampleFaker_BeerYeast() {
f := New(11)
fmt.Println(f.BeerYeast())
- // Output: 1388 - Belgian Strong Ale
+ // Output: 2308 - Munich Lager
}
func BenchmarkBeerYeast(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BeerYeast()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BeerYeast()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BeerYeast()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BeerYeast()
+ }
+
}
func ExampleBeerMalt() {
@@ -172,139 +101,67 @@ func ExampleFaker_BeerMalt() {
}
func BenchmarkBeerMalt(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BeerMalt()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BeerMalt()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BeerMalt()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BeerMalt()
+ }
}
func ExampleBeerIbu() {
Seed(11)
fmt.Println(BeerIbu())
- // Output: 47 IBU
+ // Output: 91 IBU
}
func ExampleFaker_BeerIbu() {
f := New(11)
fmt.Println(f.BeerIbu())
- // Output: 47 IBU
+ // Output: 91 IBU
}
func BenchmarkBeerIbu(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BeerIbu()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BeerIbu()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BeerIbu()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BeerIbu()
+ }
}
func ExampleBeerAlcohol() {
Seed(11)
fmt.Println(BeerAlcohol())
- // Output: 2.7%
+ // Output: 8.2%
}
func ExampleFaker_BeerAlcohol() {
f := New(11)
fmt.Println(f.BeerAlcohol())
- // Output: 2.7%
+ // Output: 8.2%
}
func BenchmarkBeerAlcohol(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BeerAlcohol()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BeerAlcohol()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BeerAlcohol()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BeerAlcohol()
+ }
}
func ExampleBeerBlg() {
Seed(11)
fmt.Println(BeerBlg())
- // Output: 6.4°Blg
+ // Output: 16.6°Blg
}
func ExampleFaker_BeerBlg() {
f := New(11)
fmt.Println(f.BeerBlg())
- // Output: 6.4°Blg
+ // Output: 16.6°Blg
}
func BenchmarkBeerBlg(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BeerBlg()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BeerBlg()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BeerBlg()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BeerBlg()
+ }
}
diff --git a/book.go b/book.go
index e2059dcf..fd8e0910 100644
--- a/book.go
+++ b/book.go
@@ -1,24 +1,22 @@
package gofakeit
-import "math/rand"
+func BookTitle() string { return bookTitle(GlobalFaker) }
-func BookTitle() string { return bookTitle(globalFaker.Rand) }
+func (f *Faker) BookTitle() string { return bookTitle(f) }
-func (f *Faker) BookTitle() string { return bookTitle(f.Rand) }
+func bookTitle(f *Faker) string { return getRandValue(f, []string{"book", "title"}) }
-func bookTitle(r *rand.Rand) string { return getRandValue(r, []string{"book", "title"}) }
+func BookAuthor() string { return bookAuthor(GlobalFaker) }
-func BookAuthor() string { return bookAuthor(globalFaker.Rand) }
+func (f *Faker) BookAuthor() string { return bookAuthor(f) }
-func (f *Faker) BookAuthor() string { return bookAuthor(f.Rand) }
+func bookAuthor(f *Faker) string { return getRandValue(f, []string{"book", "author"}) }
-func bookAuthor(r *rand.Rand) string { return getRandValue(r, []string{"book", "author"}) }
+func BookGenre() string { return bookGenre(GlobalFaker) }
-func BookGenre() string { return bookGenre(globalFaker.Rand) }
+func (f *Faker) BookGenre() string { return bookGenre(f) }
-func (f *Faker) BookGenre() string { return bookGenre(f.Rand) }
-
-func bookGenre(r *rand.Rand) string { return getRandValue(r, []string{"book", "genre"}) }
+func bookGenre(f *Faker) string { return getRandValue(f, []string{"book", "genre"}) }
type BookInfo struct {
Title string `json:"title" xml:"name"`
@@ -26,15 +24,15 @@ type BookInfo struct {
Genre string `json:"genre" xml:"genre"`
}
-func Book() *BookInfo { return book(globalFaker.Rand) }
+func Book() *BookInfo { return book(GlobalFaker) }
-func (f *Faker) Book() *BookInfo { return book(f.Rand) }
+func (f *Faker) Book() *BookInfo { return book(f) }
-func book(r *rand.Rand) *BookInfo {
+func book(f *Faker) *BookInfo {
return &BookInfo{
- Title: bookTitle(r),
- Author: bookAuthor(r),
- Genre: bookGenre(r),
+ Title: bookTitle(f),
+ Author: bookAuthor(f),
+ Genre: bookGenre(f),
}
}
@@ -50,8 +48,8 @@ func addBookLookup() {
}`,
Output: "map[string]string",
ContentType: "application/json",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return book(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return book(f), nil
},
})
@@ -61,8 +59,8 @@ func addBookLookup() {
Description: "The specific name given to a book",
Example: "Hamlet",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return bookTitle(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return bookTitle(f), nil
},
})
@@ -72,8 +70,8 @@ func addBookLookup() {
Description: "The individual who wrote or created the content of a book",
Example: "Mark Twain",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return bookAuthor(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return bookAuthor(f), nil
},
})
@@ -83,8 +81,8 @@ func addBookLookup() {
Description: "Category or type of book defined by its content, style, or form",
Example: "Adventure",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return bookGenre(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return bookGenre(f), nil
},
})
}
diff --git a/book_test.go b/book_test.go
index 12b91bb1..2128b930 100644
--- a/book_test.go
+++ b/book_test.go
@@ -12,9 +12,9 @@ func ExampleBook() {
fmt.Println(book.Author)
fmt.Println(book.Genre)
- // Output: Anna Karenina
+ // Output: Things Fall Apart
// Toni Morrison
- // Thriller
+ // Erotic
}
func ExampleFaker_Book() {
@@ -24,33 +24,15 @@ func ExampleFaker_Book() {
fmt.Println(book.Author)
fmt.Println(book.Genre)
- // Output: Anna Karenina
+ // Output: Things Fall Apart
// Toni Morrison
- // Thriller
+ // Erotic
}
func BenchmarkBook(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Book()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Book()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Book()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Book()
+ }
}
func TestBook(t *testing.T) {
@@ -63,112 +45,58 @@ func ExampleBookTitle() {
Seed(11)
fmt.Println(BookTitle())
- // Output: Anna Karenina
+ // Output: Things Fall Apart
}
func ExampleFaker_BookTitle() {
f := New(11)
fmt.Println(f.BookTitle())
- // Output: Anna Karenina
+ // Output: Things Fall Apart
}
func BenchmarkBookTitle(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BookTitle()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BookTitle()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BookTitle()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BookTitle()
+ }
}
func ExampleBookAuthor() {
Seed(11)
fmt.Println(BookAuthor())
- // Output: James Joyce
+ // Output: Vladimir Nabokov
}
func ExampleFaker_BookAuthor() {
f := New(11)
fmt.Println(f.BookAuthor())
- // Output: James Joyce
+ // Output: Vladimir Nabokov
}
func BenchmarkBookAuthor(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BookAuthor()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BookAuthor()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BookAuthor()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BookAuthor()
+ }
}
func ExampleBookGenre() {
Seed(11)
fmt.Println(BookGenre())
- // Output: Crime
+ // Output: Thriller
}
func ExampleFaker_BookGenre() {
f := New(11)
fmt.Println(f.BookGenre())
- // Output: Crime
+ // Output: Thriller
}
func BenchmarkBookGenre(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BookGenre()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BookGenre()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BookGenre()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BookGenre()
+ }
}
diff --git a/car.go b/car.go
index 983e2576..def82dc4 100644
--- a/car.go
+++ b/car.go
@@ -1,7 +1,5 @@
package gofakeit
-import "math/rand"
-
// CarInfo is a struct dataset of all car information
type CarInfo struct {
Type string `json:"type" xml:"type"`
@@ -13,63 +11,63 @@ type CarInfo struct {
}
// Car will generate a struct with car information
-func Car() *CarInfo { return car(globalFaker.Rand) }
+func Car() *CarInfo { return car(GlobalFaker) }
// Car will generate a struct with car information
-func (f *Faker) Car() *CarInfo { return car(f.Rand) }
+func (f *Faker) Car() *CarInfo { return car(f) }
-func car(r *rand.Rand) *CarInfo {
+func car(f *Faker) *CarInfo {
return &CarInfo{
- Type: carType(r),
- Fuel: carFuelType(r),
- Transmission: carTransmissionType(r),
- Brand: carMaker(r),
- Model: carModel(r),
- Year: year(r),
+ Type: carType(f),
+ Fuel: carFuelType(f),
+ Transmission: carTransmissionType(f),
+ Brand: carMaker(f),
+ Model: carModel(f),
+ Year: year(f),
}
}
// CarType will generate a random car type string
-func CarType() string { return carType(globalFaker.Rand) }
+func CarType() string { return carType(GlobalFaker) }
// CarType will generate a random car type string
-func (f *Faker) CarType() string { return carType(f.Rand) }
+func (f *Faker) CarType() string { return carType(f) }
-func carType(r *rand.Rand) string { return getRandValue(r, []string{"car", "type"}) }
+func carType(f *Faker) string { return getRandValue(f, []string{"car", "type"}) }
// CarFuelType will return a random fuel type
-func CarFuelType() string { return carFuelType(globalFaker.Rand) }
+func CarFuelType() string { return carFuelType(GlobalFaker) }
// CarFuelType will return a random fuel type
-func (f *Faker) CarFuelType() string { return carFuelType(f.Rand) }
+func (f *Faker) CarFuelType() string { return carFuelType(f) }
-func carFuelType(r *rand.Rand) string { return getRandValue(r, []string{"car", "fuel_type"}) }
+func carFuelType(f *Faker) string { return getRandValue(f, []string{"car", "fuel_type"}) }
// CarTransmissionType will return a random transmission type
-func CarTransmissionType() string { return carTransmissionType(globalFaker.Rand) }
+func CarTransmissionType() string { return carTransmissionType(GlobalFaker) }
// CarTransmissionType will return a random transmission type
-func (f *Faker) CarTransmissionType() string { return carTransmissionType(f.Rand) }
+func (f *Faker) CarTransmissionType() string { return carTransmissionType(f) }
-func carTransmissionType(r *rand.Rand) string {
- return getRandValue(r, []string{"car", "transmission_type"})
+func carTransmissionType(f *Faker) string {
+ return getRandValue(f, []string{"car", "transmission_type"})
}
// CarMaker will return a random car maker
-func CarMaker() string { return carMaker(globalFaker.Rand) }
+func CarMaker() string { return carMaker(GlobalFaker) }
// CarMaker will return a random car maker
-func (f *Faker) CarMaker() string { return carMaker(f.Rand) }
+func (f *Faker) CarMaker() string { return carMaker(f) }
-func carMaker(r *rand.Rand) string { return getRandValue(r, []string{"car", "maker"}) }
+func carMaker(f *Faker) string { return getRandValue(f, []string{"car", "maker"}) }
// CarModel will return a random car model
-func CarModel() string { return carModel(globalFaker.Rand) }
+func CarModel() string { return carModel(GlobalFaker) }
// CarModel will return a random car model
-func (f *Faker) CarModel() string { return carModel(f.Rand) }
+func (f *Faker) CarModel() string { return carModel(f) }
-func carModel(r *rand.Rand) string { return getRandValue(r, []string{"car", "model"}) }
+func carModel(f *Faker) string { return getRandValue(f, []string{"car", "model"}) }
func addCarLookup() {
AddFuncLookup("car", Info{
@@ -86,8 +84,8 @@ func addCarLookup() {
}`,
Output: "map[string]any",
ContentType: "application/json",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return car(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return car(f), nil
},
})
@@ -97,8 +95,8 @@ func addCarLookup() {
Description: "Classification of cars based on size, use, or body style",
Example: "Passenger car mini",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return carType(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return carType(f), nil
},
})
@@ -108,8 +106,8 @@ func addCarLookup() {
Description: "Type of energy source a car uses",
Example: "CNG",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return carFuelType(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return carFuelType(f), nil
},
})
@@ -119,8 +117,8 @@ func addCarLookup() {
Description: "Mechanism a car uses to transmit power from the engine to the wheels",
Example: "Manual",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return carTransmissionType(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return carTransmissionType(f), nil
},
})
@@ -130,8 +128,8 @@ func addCarLookup() {
Description: "Company or brand that manufactures and designs cars",
Example: "Nissan",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return carMaker(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return carMaker(f), nil
},
})
@@ -141,8 +139,8 @@ func addCarLookup() {
Description: "Specific design or version of a car produced by a manufacturer",
Example: "Aveo",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return carModel(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return carModel(f), nil
},
})
}
diff --git a/car_test.go b/car_test.go
index d93ff6b0..c4160b4d 100644
--- a/car_test.go
+++ b/car_test.go
@@ -15,12 +15,12 @@ func ExampleCar() {
fmt.Println(car.Type)
fmt.Println(car.Year)
- // Output: Fiat
- // Gasoline
- // Freestyle Fwd
+ // Output: Dacia
+ // CNG
+ // Santafe 4wd
// Automatic
- // Passenger car mini
- // 1965
+ // Passenger car heavy
+ // 1928
}
func ExampleFaker_Car() {
@@ -33,112 +33,58 @@ func ExampleFaker_Car() {
fmt.Println(car.Type)
fmt.Println(car.Year)
- // Output: Fiat
- // Gasoline
- // Freestyle Fwd
+ // Output: Dacia
+ // CNG
+ // Santafe 4wd
// Automatic
- // Passenger car mini
- // 1965
+ // Passenger car heavy
+ // 1928
}
func BenchmarkCar(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Car()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Car()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Car()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Car()
+ }
}
func ExampleCarType() {
Seed(11)
fmt.Println(CarType())
- // Output: Passenger car mini
+ // Output: Passenger car heavy
}
func ExampleFaker_CarType() {
f := New(11)
fmt.Println(f.CarType())
- // Output: Passenger car mini
+ // Output: Passenger car heavy
}
func BenchmarkCarType(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- CarType()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.CarType()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.CarType()
- }
- })
+ for i := 0; i < b.N; i++ {
+ CarType()
+ }
}
func ExampleCarFuelType() {
Seed(11)
fmt.Println(CarFuelType())
- // Output: CNG
+ // Output: Electric
}
func ExampleFaker_CarFuelType() {
f := New(11)
fmt.Println(f.CarFuelType())
- // Output: CNG
+ // Output: Electric
}
func BenchmarkCarFuelType(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- CarFuelType()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.CarFuelType()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.CarFuelType()
- }
- })
+ for i := 0; i < b.N; i++ {
+ CarFuelType()
+ }
}
func ExampleCarTransmissionType() {
@@ -156,101 +102,47 @@ func ExampleFaker_CarTransmissionType() {
}
func BenchmarkCarTransmissionType(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- CarTransmissionType()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.CarTransmissionType()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.CarTransmissionType()
- }
- })
+ for i := 0; i < b.N; i++ {
+ CarTransmissionType()
+ }
}
func ExampleCarMaker() {
Seed(11)
fmt.Println(CarMaker())
- // Output: Nissan
+ // Output: Spyker
}
func ExampleFaker_CarMaker() {
f := New(11)
fmt.Println(f.CarMaker())
- // Output: Nissan
+ // Output: Spyker
}
func BenchmarkCarMaker(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- CarMaker()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.CarMaker()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.CarMaker()
- }
- })
+ for i := 0; i < b.N; i++ {
+ CarMaker()
+ }
}
func ExampleCarModel() {
Seed(11)
fmt.Println(CarModel())
- // Output: Aveo
+ // Output: Prius
}
func ExampleFaker_CarModel() {
f := New(11)
fmt.Println(f.CarModel())
- // Output: Aveo
+ // Output: Prius
}
func BenchmarkCarModel(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- CarModel()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.CarModel()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.CarModel()
- }
- })
+ for i := 0; i < b.N; i++ {
+ CarModel()
+ }
}
diff --git a/celebrity.go b/celebrity.go
index d7400f80..b00036d8 100644
--- a/celebrity.go
+++ b/celebrity.go
@@ -1,32 +1,30 @@
package gofakeit
-import "math/rand"
-
// CelebrityActor will generate a random celebrity actor
-func CelebrityActor() string { return celebrityActor(globalFaker.Rand) }
+func CelebrityActor() string { return celebrityActor(GlobalFaker) }
// CelebrityActor will generate a random celebrity actor
-func (f *Faker) CelebrityActor() string { return celebrityActor(f.Rand) }
+func (f *Faker) CelebrityActor() string { return celebrityActor(f) }
-func celebrityActor(r *rand.Rand) string { return getRandValue(r, []string{"celebrity", "actor"}) }
+func celebrityActor(f *Faker) string { return getRandValue(f, []string{"celebrity", "actor"}) }
// CelebrityBusiness will generate a random celebrity business person
-func CelebrityBusiness() string { return celebrityBusiness(globalFaker.Rand) }
+func CelebrityBusiness() string { return celebrityBusiness(GlobalFaker) }
// CelebrityBusiness will generate a random celebrity business person
-func (f *Faker) CelebrityBusiness() string { return celebrityBusiness(f.Rand) }
+func (f *Faker) CelebrityBusiness() string { return celebrityBusiness(f) }
-func celebrityBusiness(r *rand.Rand) string {
- return getRandValue(r, []string{"celebrity", "business"})
+func celebrityBusiness(f *Faker) string {
+ return getRandValue(f, []string{"celebrity", "business"})
}
// CelebritySport will generate a random celebrity sport person
-func CelebritySport() string { return celebritySport(globalFaker.Rand) }
+func CelebritySport() string { return celebritySport(GlobalFaker) }
// CelebritySport will generate a random celebrity sport person
-func (f *Faker) CelebritySport() string { return celebritySport(f.Rand) }
+func (f *Faker) CelebritySport() string { return celebritySport(f) }
-func celebritySport(r *rand.Rand) string { return getRandValue(r, []string{"celebrity", "sport"}) }
+func celebritySport(f *Faker) string { return getRandValue(f, []string{"celebrity", "sport"}) }
func addCelebrityLookup() {
AddFuncLookup("celebrityactor", Info{
@@ -35,8 +33,8 @@ func addCelebrityLookup() {
Description: "Famous person known for acting in films, television, or theater",
Example: "Brad Pitt",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return celebrityActor(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return celebrityActor(f), nil
},
})
@@ -46,8 +44,8 @@ func addCelebrityLookup() {
Description: "High-profile individual known for significant achievements in business or entrepreneurship",
Example: "Elon Musk",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return celebrityBusiness(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return celebrityBusiness(f), nil
},
})
@@ -57,8 +55,8 @@ func addCelebrityLookup() {
Description: "Famous athlete known for achievements in a particular sport",
Example: "Michael Phelps",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return celebritySport(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return celebritySport(f), nil
},
})
}
diff --git a/celebrity_test.go b/celebrity_test.go
index 2994fd49..b431a4fb 100644
--- a/celebrity_test.go
+++ b/celebrity_test.go
@@ -9,112 +9,58 @@ func ExampleCelebrityActor() {
Seed(11)
fmt.Println(CelebrityActor())
- // Output: Owen Wilson
+ // Output: Shah Rukh Khan
}
func ExampleFaker_CelebrityActor() {
f := New(11)
fmt.Println(f.CelebrityActor())
- // Output: Owen Wilson
+ // Output: Shah Rukh Khan
}
func BenchmarkCelebrityActor(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- CelebrityActor()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.CelebrityActor()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.CelebrityActor()
- }
- })
+ for i := 0; i < b.N; i++ {
+ CelebrityActor()
+ }
}
func ExampleCelebrityBusiness() {
Seed(11)
fmt.Println(CelebrityBusiness())
- // Output: Cameron Diaz
+ // Output: Prescott Bush
}
func ExampleFaker_CelebrityBusiness() {
f := New(11)
fmt.Println(f.CelebrityBusiness())
- // Output: Cameron Diaz
+ // Output: Prescott Bush
}
func BenchmarkCelebrityBusiness(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- CelebrityBusiness()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.CelebrityBusiness()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.CelebrityBusiness()
- }
- })
+ for i := 0; i < b.N; i++ {
+ CelebrityBusiness()
+ }
}
func ExampleCelebritySport() {
Seed(11)
fmt.Println(CelebritySport())
- // Output: Hicham El Guerrouj
+ // Output: Grete Waitz
}
func ExampleFaker_CelebritySport() {
f := New(11)
fmt.Println(f.CelebritySport())
- // Output: Hicham El Guerrouj
+ // Output: Grete Waitz
}
func BenchmarkCelebritySport(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- CelebritySport()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.CelebritySport()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.CelebritySport()
- }
- })
+ for i := 0; i < b.N; i++ {
+ CelebritySport()
+ }
}
diff --git a/cmd/exampleupdate/main.go b/cmd/exampleupdate/main.go
new file mode 100644
index 00000000..fffc7cc2
--- /dev/null
+++ b/cmd/exampleupdate/main.go
@@ -0,0 +1,252 @@
+package main
+
+import (
+ "errors"
+ "fmt"
+ "os"
+ "os/exec"
+ "regexp"
+ "strings"
+ "sync"
+)
+
+func main() {
+ entries, err := os.ReadDir(".")
+ if err != nil {
+ fmt.Println("Error reading directory:", err)
+ return
+ }
+
+ // Add wait group to wait for all examples to finish
+ var wg sync.WaitGroup
+
+ for _, entry := range entries {
+ if !entry.IsDir() {
+ filename := entry.Name()
+ if isTestFile(filename) {
+ // Add to wait group
+ wg.Add(1)
+
+ // go func() {
+
+ // Process the file in a goroutine
+ fmt.Println("Processing file:", filename)
+ if err := processTestFile(filename); err != nil {
+ fmt.Println("Error processing test file:\n", err)
+ return // Stop processing further if any example fails
+ }
+
+ fmt.Println()
+
+ // time.Sleep(1 * time.Second)
+
+ // Done with the file
+ wg.Done()
+
+ // }()
+ }
+ }
+ }
+
+ // Wait for all examples to finish
+ wg.Wait()
+}
+
+func isTestFile(filename string) bool {
+ return regexp.MustCompile(`_test\.go$`).MatchString(filename)
+}
+
+func findExampleFunctions(filename string) ([]string, error) {
+ // ReRead the content after each example
+ fileContentBytes, err := os.ReadFile(filename)
+ if err != nil {
+ return nil, fmt.Errorf("error reading file %s: %w", filename, err)
+ }
+ fileContent := string(fileContentBytes)
+
+ var examples []string
+ r := regexp.MustCompile(`func Example[^(]*\(\)`)
+ matches := r.FindAllString(fileContent, -1)
+
+ for _, match := range matches {
+ exampleName := match[5:] // Remove "func " prefix to get the example function name
+ examples = append(examples, exampleName)
+ }
+
+ return examples, nil
+}
+
+func processTestFile(filename string) error {
+ examples, err := findExampleFunctions(filename)
+ if err != nil {
+ return fmt.Errorf("error finding example functions in file %s: %w", filename, err)
+ }
+
+ // Test the filename as a hole first
+ // go test -run ^(strings.Join(examples, "|"))$
+ TestPassCmd := exec.Command("go", "test", "-run", "^("+strings.Join(examples, "|")+")$")
+ _, err = TestPassCmd.CombinedOutput()
+ if err == nil {
+ fmt.Println("Success")
+ // fmt.Printf("file %s passed successfully on first run\n", filename)
+ return nil
+ }
+
+ for _, example := range examples {
+ // ReRead the content after each example
+ content, err := os.ReadFile(filename)
+ if err != nil {
+ return fmt.Errorf("error reading file %s: %w", filename, err)
+ }
+
+ if err := runAndUpdateExample(filename, example, string(content)); err != nil {
+ return err // Return the error to stop further processing
+ }
+
+ // Give some space in the output
+ fmt.Println()
+ }
+ return nil
+}
+
+func runAndUpdateExample(filename, exampleName, content string) error {
+ fmt.Println("Testing: ", exampleName)
+ firstRunCmd := exec.Command("go", "test", "-run", exampleName+"$")
+ firstOutput, err := firstRunCmd.CombinedOutput()
+ if err == nil {
+ fmt.Println("Success")
+ // fmt.Printf("example %s in file %s passed successfully on first run\n", exampleName, filename)
+ return nil
+ }
+
+ // fmt.Printf("firstOutput: %s\n", string(firstOutput))
+
+ // If the example failed, output the error and continue
+ fmt.Println("Failed, running update")
+ // fmt.Printf("example %s in file %s failed on first run: %s\n", exampleName, filename, err)
+
+ // Parse the output to get "got" and "want"
+ got, want := parseOutputForGotAndWant(string(firstOutput))
+ if got == "" || want == "" {
+ return fmt.Errorf("example %s in file %s failed, but unable to parse got/want: %s", exampleName, filename, err)
+ }
+
+ // fmt.Printf("Got:\n%s\n\nWant:\n%s\n", got, want)
+
+ // Update the file with "got" as new output
+ newContent, err := updateExampleOutputInFileContent(content, exampleName, got)
+ if err != nil {
+ return fmt.Errorf("error updating example %s in file %s: %s", exampleName, filename, err)
+ }
+ if newContent == "" {
+ return fmt.Errorf("failed to update example %s in file %s with new output", exampleName, filename)
+ }
+
+ if err := os.WriteFile(filename, []byte(newContent), 0644); err != nil {
+ return fmt.Errorf("error writing updated file %s: %s", filename, err)
+ }
+
+ // time.Sleep(1 * time.Second)
+
+ // Rerun the example after updating
+ secondRunCmd := exec.Command("go", "test", "-run", exampleName+"$")
+ secondOutput, err := secondRunCmd.CombinedOutput()
+ if err != nil {
+ return fmt.Errorf("example %s in file %s failed after update: %s\nOutput:\n%s", exampleName, filename, err, string(secondOutput))
+ }
+
+ fmt.Println("Success after update")
+ // fmt.Printf("example %s in file %s passed successfully after update\n", exampleName, filename)
+ return nil
+}
+
+func parseOutputForGotAndWant(output string) (got, want string) {
+ gotRegex := regexp.MustCompile(`(?s)got:\n(.*?)\nwant:`)
+ wantRegex := regexp.MustCompile(`(?s)want:\n(.*)`)
+
+ gotMatch := gotRegex.FindStringSubmatch(output)
+ wantMatch := wantRegex.FindStringSubmatch(output)
+
+ if len(gotMatch) > 1 {
+ got = gotMatch[1]
+ }
+ if len(wantMatch) > 1 {
+ want = wantMatch[1]
+ }
+
+ return strings.TrimSpace(got), strings.TrimSpace(want)
+}
+
+func updateExampleOutputInFileContent(content, exampleName, newOutput string) (string, error) {
+ lines := strings.Split(content, "\n")
+ foundExample := false
+ foundOutputMarker := false
+ exampleStart := fmt.Sprintf("func %s", exampleName) // func ExampleCusip()
+ fmt.Println(exampleStart)
+ outputMarker := "// Output:"
+
+ // Prepare the new output lines, each prefixed with "// "
+ outputLines := strings.Split(newOutput, "\n")
+ for i, line := range outputLines {
+ // Add // Output: prefix to the first line
+ if i == 0 {
+ // Starting with [tab]// Output:
+ outputLines[i] = " " + outputMarker + " " + line
+ continue
+ }
+
+ // Starting with [tab]//[space]
+ outputLines[i] = " // " + line
+ }
+
+ startComment := 0
+ endComment := 0
+ for i, line := range lines {
+ // If you have started the comment figure out the end
+ if foundExample && foundOutputMarker {
+ // Check if current row starts with // if so continue
+ if strings.HasPrefix(strings.TrimSpace(line), "//") {
+ continue
+ } else {
+ // If we are here we are at the end of the comment
+ endComment = i
+ break
+ }
+ }
+
+ // Found example function
+ if strings.Contains(line, exampleStart) {
+ foundExample = true
+ }
+
+ // Found output marker
+ if foundExample && strings.Contains(line, outputMarker) {
+ // Mark that we found the output marker and start inserting new output lines
+ foundOutputMarker = true
+ startComment = i
+
+ continue
+ }
+ }
+
+ if !foundExample {
+ return "", errors.New(exampleName + " not found in example function")
+ }
+
+ if !foundOutputMarker {
+ return "", errors.New("output marker not found in example function")
+ }
+
+ // If startComment and endComment are 0 then error
+ if startComment == 0 && endComment == 0 {
+ return "", errors.New("start and end comment not found")
+ }
+
+ // fmt.Printf("Start: %d, End: %d\n\n", startComment, endComment)
+
+ // Loop through the lines deleting the old output
+ // and inserting the new output
+ lines = append(lines[:startComment], append(outputLines, lines[endComment:]...)...)
+
+ return strings.Join(lines, "\n"), nil
+}
diff --git a/cmd/gofakeit/README.md b/cmd/gofakeit/README.md
index d06bee66..1ca0708e 100644
--- a/cmd/gofakeit/README.md
+++ b/cmd/gofakeit/README.md
@@ -6,7 +6,7 @@ All functions are available to run in lowercase and if they require additional p
### Installation
```go
-go install -v github.com/brianvoe/gofakeit/v6/cmd/gofakeit@latest
+go install -v github.com/brianvoe/gofakeit/v7/cmd/gofakeit@latest
```
### Example
diff --git a/cmd/gofakeit/gofakeit.go b/cmd/gofakeit/gofakeit.go
index 4247ae30..578ae052 100644
--- a/cmd/gofakeit/gofakeit.go
+++ b/cmd/gofakeit/gofakeit.go
@@ -8,7 +8,7 @@ import (
"strconv"
"strings"
- "github.com/brianvoe/gofakeit/v6"
+ "github.com/brianvoe/gofakeit/v7"
)
var errNoFuncRunMsg = errors.New("could not find function to run\nrun gofakeit help or gofakeit list for available functions")
@@ -50,7 +50,7 @@ func main() {
fmt.Printf("%s", out)
}
-func mainFunc(seed int64, args []string, loop int) (string, error) {
+func mainFunc(seed uint64, args []string, loop int) (string, error) {
faker := gofakeit.New(seed)
argsLen := len(args)
@@ -142,7 +142,7 @@ func runFunction(faker *gofakeit.Faker, function string, args []string) (string,
}
}
- value, err := info.Generate(faker.Rand, params, info)
+ value, err := info.Generate(faker, params, info)
if err != nil {
return "", err
}
diff --git a/cmd/gofakeit/gofakeit_test.go b/cmd/gofakeit/gofakeit_test.go
index 4609a79b..68cb387a 100644
--- a/cmd/gofakeit/gofakeit_test.go
+++ b/cmd/gofakeit/gofakeit_test.go
@@ -7,7 +7,7 @@ import (
"strings"
"testing"
- "github.com/brianvoe/gofakeit/v6/data"
+ "github.com/brianvoe/gofakeit/v7/data"
)
func TestMain(t *testing.T) {
@@ -69,7 +69,7 @@ func TestFunctionLoop(t *testing.T) {
}
func TestNotEnoughArgs(t *testing.T) {
- seed := int64(11)
+ seed := uint64(11)
args := []string{}
_, err := mainFunc(seed, args, 1)
@@ -79,7 +79,7 @@ func TestNotEnoughArgs(t *testing.T) {
}
func TestNoFunction(t *testing.T) {
- seed := int64(11)
+ seed := uint64(11)
args := []string{"notafunction"}
_, err := mainFunc(seed, args, 1)
@@ -89,7 +89,7 @@ func TestNoFunction(t *testing.T) {
}
func TestFunctionSimple(t *testing.T) {
- seed := int64(11)
+ seed := uint64(11)
args := []string{"firstname"}
outStr, err := mainFunc(seed, args, 1)
@@ -114,7 +114,7 @@ func TestFunctionSimple(t *testing.T) {
func TestFunctionWithParams(t *testing.T) {
strs := []string{"hello", "world", "whats", "up"}
- seed := int64(11)
+ seed := uint64(11)
args := []string{"shufflestrings", strings.Join(strs, ",")}
outStr, err := mainFunc(seed, args, 1)
@@ -128,7 +128,7 @@ func TestFunctionWithParams(t *testing.T) {
}
func TestHelp(t *testing.T) {
- seed := int64(11)
+ seed := uint64(11)
args := []string{"help"}
outStr, err := mainFunc(seed, args, 1)
@@ -149,7 +149,7 @@ func TestHelp(t *testing.T) {
}
func TestList(t *testing.T) {
- seed := int64(11)
+ seed := uint64(11)
args := []string{"list"}
outStr, err := mainFunc(seed, args, 1)
@@ -176,7 +176,7 @@ func TestList(t *testing.T) {
}
func TestListCategory(t *testing.T) {
- seed := int64(11)
+ seed := uint64(11)
args := []string{"list", "person"}
outStr, err := mainFunc(seed, args, 1)
@@ -200,7 +200,7 @@ func TestListCategory(t *testing.T) {
}
func TestListCategoryFunction(t *testing.T) {
- seed := int64(11)
+ seed := uint64(11)
args := []string{"list", "word", "noun"}
outStr, err := mainFunc(seed, args, 1)
diff --git a/cmd/gofakeitserver/README.md b/cmd/gofakeitserver/README.md
index 849c98fb..4d0ba198 100644
--- a/cmd/gofakeitserver/README.md
+++ b/cmd/gofakeitserver/README.md
@@ -4,7 +4,7 @@ All functions are available to run in lowercase as first path and if they take i
### Installation
```go
-go get -u github.com/brianvoe/gofakeit/v6/cmd/gofakeitserver
+go get -u github.com/brianvoe/gofakeit/v7/cmd/gofakeitserver
```
### Example
diff --git a/cmd/gofakeitserver/init_test.go b/cmd/gofakeitserver/init_test.go
index 18410c46..6f637e77 100644
--- a/cmd/gofakeitserver/init_test.go
+++ b/cmd/gofakeitserver/init_test.go
@@ -12,7 +12,7 @@ import (
"strings"
"testing"
- "github.com/brianvoe/gofakeit/v6"
+ "github.com/brianvoe/gofakeit/v7"
)
var ts *httptest.Server
diff --git a/cmd/gofakeitserver/main.go b/cmd/gofakeitserver/main.go
index 3d394e47..c1880872 100644
--- a/cmd/gofakeitserver/main.go
+++ b/cmd/gofakeitserver/main.go
@@ -10,7 +10,7 @@ import (
"reflect"
"strings"
- "github.com/brianvoe/gofakeit/v6"
+ "github.com/brianvoe/gofakeit/v7"
)
var port string
@@ -83,7 +83,7 @@ func lookupGet(w http.ResponseWriter, r *http.Request) {
}
// Generate requested data
- data, err := info.Generate(faker.Rand, m, info)
+ data, err := info.Generate(faker, m, info)
if err != nil {
badrequest(w, err.Error())
return
@@ -149,7 +149,7 @@ func lookupPost(w http.ResponseWriter, r *http.Request) {
}
// Generate requested data
- data, err := info.Generate(faker.Rand, mapString, info)
+ data, err := info.Generate(faker, mapString, info)
if err != nil {
badrequest(w, err.Error())
return
diff --git a/cmd/gofakeitserver/main_test.go b/cmd/gofakeitserver/main_test.go
index 050397e4..3120b38c 100644
--- a/cmd/gofakeitserver/main_test.go
+++ b/cmd/gofakeitserver/main_test.go
@@ -2,12 +2,12 @@ package main
import (
"fmt"
- "math/rand"
+ "math/rand/v2"
"net/url"
"strings"
"testing"
- "github.com/brianvoe/gofakeit/v6"
+ "github.com/brianvoe/gofakeit/v7"
)
func TestList(t *testing.T) {
@@ -38,7 +38,7 @@ func TestGetAllRequests(t *testing.T) {
for _, p := range info.Params {
// If default is empty and has options randomly pick one
if p.Default == "" && len(p.Options) != 0 {
- mapData.Add(p.Field, p.Options[faker.Rand.Intn(len(p.Options))])
+ mapData.Add(p.Field, p.Options[faker.IntN(len(p.Options))])
continue
} else if p.Default != "" {
// If p.Type is []uint, then we need to convert it to []string
@@ -174,7 +174,7 @@ func TestPostAllRequests(t *testing.T) {
for _, p := range info.Params {
// If default is empty and has options randomly pick one
if p.Default == "" && len(p.Options) != 0 {
- mapData[p.Field] = []string{p.Options[rand.Intn(len(p.Options))]}
+ mapData[p.Field] = []string{p.Options[rand.IntN(len(p.Options))]}
continue
} else if p.Default != "" {
// If p.Type is []uint, then we need to convert it to []string
diff --git a/color.go b/color.go
index dce7db5f..e8feb402 100644
--- a/color.go
+++ b/color.go
@@ -1,61 +1,59 @@
package gofakeit
import (
- "math/rand"
-
- "github.com/brianvoe/gofakeit/v6/data"
+ "github.com/brianvoe/gofakeit/v7/data"
)
// Color will generate a random color string
-func Color() string { return color(globalFaker.Rand) }
+func Color() string { return color(GlobalFaker) }
// Color will generate a random color string
-func (f *Faker) Color() string { return color(f.Rand) }
+func (f *Faker) Color() string { return color(f) }
-func color(r *rand.Rand) string { return getRandValue(r, []string{"color", "full"}) }
+func color(f *Faker) string { return getRandValue(f, []string{"color", "full"}) }
// NiceColor will generate a random safe color string
-func NiceColors() []string { return niceColors(globalFaker.Rand) }
+func NiceColors() []string { return niceColors(GlobalFaker) }
// NiceColor will generate a random safe color string
-func (f *Faker) NiceColors() []string { return niceColors(f.Rand) }
+func (f *Faker) NiceColors() []string { return niceColors(f) }
-func niceColors(r *rand.Rand) []string {
- return data.ColorsNice[randIntRange(r, 0, len(data.ColorsNice)-1)]
+func niceColors(f *Faker) []string {
+ return data.ColorsNice[randIntRange(f, 0, len(data.ColorsNice)-1)]
}
// SafeColor will generate a random safe color string
-func SafeColor() string { return safeColor(globalFaker.Rand) }
+func SafeColor() string { return safeColor(GlobalFaker) }
// SafeColor will generate a random safe color string
-func (f *Faker) SafeColor() string { return safeColor(f.Rand) }
+func (f *Faker) SafeColor() string { return safeColor(f) }
-func safeColor(r *rand.Rand) string { return getRandValue(r, []string{"color", "safe"}) }
+func safeColor(f *Faker) string { return getRandValue(f, []string{"color", "safe"}) }
// HexColor will generate a random hexadecimal color string
-func HexColor() string { return hexColor(globalFaker.Rand) }
+func HexColor() string { return hexColor(GlobalFaker) }
// HexColor will generate a random hexadecimal color string
-func (f *Faker) HexColor() string { return hexColor(f.Rand) }
+func (f *Faker) HexColor() string { return hexColor(f) }
-func hexColor(r *rand.Rand) string {
+func hexColor(f *Faker) string {
color := make([]byte, 6)
hashQuestion := []byte("?#")
for i := 0; i < 6; i++ {
- color[i] = hashQuestion[r.Intn(2)]
+ color[i] = hashQuestion[f.IntN(2)]
}
- return "#" + replaceWithHexLetters(r, replaceWithNumbers(r, string(color)))
+ return "#" + replaceWithHexLetters(f, replaceWithNumbers(f, string(color)))
}
// RGBColor will generate a random int slice color
-func RGBColor() []int { return rgbColor(globalFaker.Rand) }
+func RGBColor() []int { return rgbColor(GlobalFaker) }
// RGBColor will generate a random int slice color
-func (f *Faker) RGBColor() []int { return rgbColor(f.Rand) }
+func (f *Faker) RGBColor() []int { return rgbColor(f) }
-func rgbColor(r *rand.Rand) []int {
- return []int{randIntRange(r, 0, 255), randIntRange(r, 0, 255), randIntRange(r, 0, 255)}
+func rgbColor(f *Faker) []int {
+ return []int{randIntRange(f, 0, 255), randIntRange(f, 0, 255), randIntRange(f, 0, 255)}
}
func addColorLookup() {
@@ -65,8 +63,8 @@ func addColorLookup() {
Description: "Hue seen by the eye, returns the name of the color like red or blue",
Example: "MediumOrchid",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return color(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return color(f), nil
},
})
@@ -77,8 +75,8 @@ func addColorLookup() {
Example: `["#cfffdd","#b4dec1","#5c5863","#a85163","#ff1f4c"]`,
Output: "[]string",
ContentType: "application/json",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return color(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return color(f), nil
},
})
@@ -88,8 +86,8 @@ func addColorLookup() {
Description: "Colors displayed consistently on different web browsers and devices",
Example: "black",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return safeColor(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return safeColor(f), nil
},
})
@@ -99,8 +97,8 @@ func addColorLookup() {
Description: "Six-digit code representing a color in the color model",
Example: "#a99fb4",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return hexColor(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return hexColor(f), nil
},
})
@@ -111,8 +109,8 @@ func addColorLookup() {
Example: "[85, 224, 195]",
Output: "[]int",
ContentType: "application/json",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return rgbColor(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return rgbColor(f), nil
},
})
}
diff --git a/color_test.go b/color_test.go
index 5cafa62a..e892c401 100644
--- a/color_test.go
+++ b/color_test.go
@@ -9,188 +9,98 @@ func ExampleColor() {
Seed(11)
fmt.Println(Color())
- // Output: MediumOrchid
+ // Output: SlateGray
}
func ExampleFaker_Color() {
f := New(11)
fmt.Println(f.Color())
- // Output: MediumOrchid
+ // Output: SlateGray
}
func BenchmarkColor(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Color()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Color()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Color()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Color()
+ }
}
func ExampleNiceColors() {
Seed(11)
fmt.Println(NiceColors())
- // Output: [#f6f6f6 #e8e8e8 #333333 #990100 #b90504]
+ // Output: [#fffbb7 #a6f6af #66b6ab #5b7c8d #4f2958]
}
func ExampleFaker_NiceColors() {
f := New(11)
fmt.Println(f.NiceColors())
- // Output: [#f6f6f6 #e8e8e8 #333333 #990100 #b90504]
+ // Output: [#fffbb7 #a6f6af #66b6ab #5b7c8d #4f2958]
}
func BenchmarkNiceColors(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- NiceColors()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.NiceColors()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.NiceColors()
- }
- })
+ for i := 0; i < b.N; i++ {
+ NiceColors()
+ }
}
func ExampleSafeColor() {
Seed(11)
fmt.Println(SafeColor())
- // Output: black
+ // Output: aqua
}
func ExampleFaker_SafeColor() {
f := New(11)
fmt.Println(f.SafeColor())
- // Output: black
+ // Output: aqua
}
func BenchmarkSafeColor(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- SafeColor()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.SafeColor()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.SafeColor()
- }
- })
+ for i := 0; i < b.N; i++ {
+ SafeColor()
+ }
}
func ExampleHexColor() {
Seed(11)
fmt.Println(HexColor())
- // Output: #a99fb4
+ // Output: #ef759a
}
func ExampleFaker_HexColor() {
f := New(11)
fmt.Println(f.HexColor())
- // Output: #a99fb4
+ // Output: #ef759a
}
func BenchmarkHexColor(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- HexColor()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.HexColor()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.HexColor()
- }
- })
+ for i := 0; i < b.N; i++ {
+ HexColor()
+ }
}
func ExampleRGBColor() {
Seed(11)
fmt.Println(RGBColor())
- // Output: [89 176 195]
+ // Output: [180 18 181]
}
func ExampleFaker_RGBColor() {
f := New(11)
fmt.Println(f.RGBColor())
- // Output: [89 176 195]
+ // Output: [180 18 181]
}
func BenchmarkRGBColor(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- RGBColor()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.RGBColor()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.RGBColor()
- }
- })
+ for i := 0; i < b.N; i++ {
+ RGBColor()
+ }
}
diff --git a/company.go b/company.go
index ea8af6ca..64167295 100644
--- a/company.go
+++ b/company.go
@@ -1,45 +1,43 @@
package gofakeit
-import "math/rand"
-
// Company will generate a random company name string
-func Company() string { return company(globalFaker.Rand) }
+func Company() string { return company(GlobalFaker) }
// Company will generate a random company name string
-func (f *Faker) Company() string { return company(f.Rand) }
+func (f *Faker) Company() string { return company(f) }
-func company(r *rand.Rand) string { return getRandValue(r, []string{"company", "name"}) }
+func company(f *Faker) string { return getRandValue(f, []string{"company", "name"}) }
// CompanySuffix will generate a random company suffix string
-func CompanySuffix() string { return companySuffix(globalFaker.Rand) }
+func CompanySuffix() string { return companySuffix(GlobalFaker) }
// CompanySuffix will generate a random company suffix string
-func (f *Faker) CompanySuffix() string { return companySuffix(f.Rand) }
+func (f *Faker) CompanySuffix() string { return companySuffix(f) }
-func companySuffix(r *rand.Rand) string { return getRandValue(r, []string{"company", "suffix"}) }
+func companySuffix(f *Faker) string { return getRandValue(f, []string{"company", "suffix"}) }
// Blurb will generate a random company blurb string
-func Blurb() string { return blurb(globalFaker.Rand) }
+func Blurb() string { return blurb(GlobalFaker) }
-func (f *Faker) Blurb() string { return blurb(f.Rand) }
+func (f *Faker) Blurb() string { return blurb(f) }
-func blurb(r *rand.Rand) string { return getRandValue(r, []string{"company", "blurb"}) }
+func blurb(f *Faker) string { return getRandValue(f, []string{"company", "blurb"}) }
// BuzzWord will generate a random company buzz word string
-func BuzzWord() string { return buzzWord(globalFaker.Rand) }
+func BuzzWord() string { return buzzWord(GlobalFaker) }
// BuzzWord will generate a random company buzz word string
-func (f *Faker) BuzzWord() string { return buzzWord(f.Rand) }
+func (f *Faker) BuzzWord() string { return buzzWord(f) }
-func buzzWord(r *rand.Rand) string { return getRandValue(r, []string{"company", "buzzwords"}) }
+func buzzWord(f *Faker) string { return getRandValue(f, []string{"company", "buzzwords"}) }
// BS will generate a random company bs string
-func BS() string { return bs(globalFaker.Rand) }
+func BS() string { return bs(GlobalFaker) }
// BS will generate a random company bs string
-func (f *Faker) BS() string { return bs(f.Rand) }
+func (f *Faker) BS() string { return bs(f) }
-func bs(r *rand.Rand) string { return getRandValue(r, []string{"company", "bs"}) }
+func bs(f *Faker) string { return getRandValue(f, []string{"company", "bs"}) }
// JobInfo is a struct of job information
type JobInfo struct {
@@ -50,64 +48,64 @@ type JobInfo struct {
}
// Job will generate a struct with random job information
-func Job() *JobInfo { return job(globalFaker.Rand) }
+func Job() *JobInfo { return job(GlobalFaker) }
// Job will generate a struct with random job information
-func (f *Faker) Job() *JobInfo { return job(f.Rand) }
+func (f *Faker) Job() *JobInfo { return job(f) }
-func job(r *rand.Rand) *JobInfo {
+func job(f *Faker) *JobInfo {
return &JobInfo{
- Company: company(r),
- Title: jobTitle(r),
- Descriptor: jobDescriptor(r),
- Level: jobLevel(r),
+ Company: company(f),
+ Title: jobTitle(f),
+ Descriptor: jobDescriptor(f),
+ Level: jobLevel(f),
}
}
// JobTitle will generate a random job title string
-func JobTitle() string { return jobTitle(globalFaker.Rand) }
+func JobTitle() string { return jobTitle(GlobalFaker) }
// JobTitle will generate a random job title string
-func (f *Faker) JobTitle() string { return jobTitle(f.Rand) }
+func (f *Faker) JobTitle() string { return jobTitle(f) }
-func jobTitle(r *rand.Rand) string { return getRandValue(r, []string{"job", "title"}) }
+func jobTitle(f *Faker) string { return getRandValue(f, []string{"job", "title"}) }
// JobDescriptor will generate a random job descriptor string
-func JobDescriptor() string { return jobDescriptor(globalFaker.Rand) }
+func JobDescriptor() string { return jobDescriptor(GlobalFaker) }
// JobDescriptor will generate a random job descriptor string
-func (f *Faker) JobDescriptor() string { return jobDescriptor(f.Rand) }
+func (f *Faker) JobDescriptor() string { return jobDescriptor(f) }
-func jobDescriptor(r *rand.Rand) string { return getRandValue(r, []string{"job", "descriptor"}) }
+func jobDescriptor(f *Faker) string { return getRandValue(f, []string{"job", "descriptor"}) }
// JobLevel will generate a random job level string
-func JobLevel() string { return jobLevel(globalFaker.Rand) }
+func JobLevel() string { return jobLevel(GlobalFaker) }
// JobLevel will generate a random job level string
-func (f *Faker) JobLevel() string { return jobLevel(f.Rand) }
+func (f *Faker) JobLevel() string { return jobLevel(f) }
-func jobLevel(r *rand.Rand) string { return getRandValue(r, []string{"job", "level"}) }
+func jobLevel(f *Faker) string { return getRandValue(f, []string{"job", "level"}) }
// Slogan will generate a random company slogan
-func Slogan() string { return slogan(globalFaker.Rand) }
+func Slogan() string { return slogan(GlobalFaker) }
// Slogan will generate a random company slogan
-func (f *Faker) Slogan() string { return slogan(f.Rand) }
+func (f *Faker) Slogan() string { return slogan(f) }
// Slogan will generate a random company slogan
-func slogan(r *rand.Rand) string {
+func slogan(f *Faker) string {
slogan := ""
- var sloganStyle = number(r, 0, 2)
+ var sloganStyle = number(f, 0, 2)
switch sloganStyle {
// Noun. Buzzword!
case 0:
- slogan = getRandValue(r, []string{"company", "blurb"}) + ". " + getRandValue(r, []string{"company", "buzzwords"}) + "!"
+ slogan = getRandValue(f, []string{"company", "blurb"}) + ". " + getRandValue(f, []string{"company", "buzzwords"}) + "!"
// Buzzword Noun, Buzzword Noun.
case 1:
- slogan = getRandValue(r, []string{"company", "buzzwords"}) + " " + getRandValue(r, []string{"company", "blurb"}) + ", " + getRandValue(r, []string{"company", "buzzwords"}) + " " + getRandValue(r, []string{"company", "blurb"}) + "."
+ slogan = getRandValue(f, []string{"company", "buzzwords"}) + " " + getRandValue(f, []string{"company", "blurb"}) + ", " + getRandValue(f, []string{"company", "buzzwords"}) + " " + getRandValue(f, []string{"company", "blurb"}) + "."
// Buzzword bs Noun, Buzzword.
case 2:
- slogan = getRandValue(r, []string{"company", "buzzwords"}) + " " + getRandValue(r, []string{"company", "bs"}) + " " + getRandValue(r, []string{"company", "blurb"}) + ", " + getRandValue(r, []string{"company", "buzzwords"}) + "."
+ slogan = getRandValue(f, []string{"company", "buzzwords"}) + " " + getRandValue(f, []string{"company", "bs"}) + " " + getRandValue(f, []string{"company", "blurb"}) + ", " + getRandValue(f, []string{"company", "buzzwords"}) + "."
}
return slogan
}
@@ -119,8 +117,8 @@ func addCompanyLookup() {
Description: "Designated official name of a business or organization",
Example: "Moen, Pagac and Wuckert",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return company(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return company(f), nil
},
})
@@ -130,8 +128,8 @@ func addCompanyLookup() {
Description: "Suffix at the end of a company name, indicating business structure, like 'Inc.' or 'LLC'",
Example: "Inc",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return companySuffix(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return companySuffix(f), nil
},
})
@@ -141,8 +139,8 @@ func addCompanyLookup() {
Description: "Random bs company word",
Example: "front-end",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return bs(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return bs(f), nil
},
})
@@ -152,8 +150,8 @@ func addCompanyLookup() {
Description: "Brief description or summary of a company's purpose, products, or services",
Example: "word",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return blurb(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return blurb(f), nil
},
})
@@ -163,8 +161,8 @@ func addCompanyLookup() {
Description: "Trendy or overused term often used in business to sound impressive",
Example: "disintermediate",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return buzzWord(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return buzzWord(f), nil
},
})
@@ -180,8 +178,8 @@ func addCompanyLookup() {
}`,
Output: "map[string]string",
ContentType: "application/json",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return job(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return job(f), nil
},
})
@@ -191,8 +189,8 @@ func addCompanyLookup() {
Description: "Specific title for a position or role within a company or organization",
Example: "Director",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return jobTitle(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return jobTitle(f), nil
},
})
@@ -202,8 +200,8 @@ func addCompanyLookup() {
Description: "Word used to describe the duties, requirements, and nature of a job",
Example: "Central",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return jobDescriptor(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return jobDescriptor(f), nil
},
})
@@ -213,8 +211,8 @@ func addCompanyLookup() {
Description: "Random job level",
Example: "Assurance",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return jobLevel(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return jobLevel(f), nil
},
})
@@ -224,8 +222,8 @@ func addCompanyLookup() {
Description: "Catchphrase or motto used by a company to represent its brand or values",
Example: "Universal seamless Focus, interactive.",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return slogan(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return slogan(f), nil
},
})
}
diff --git a/company_test.go b/company_test.go
index fb99cf3c..5a62a066 100644
--- a/company_test.go
+++ b/company_test.go
@@ -9,38 +9,20 @@ func ExampleCompany() {
Seed(11)
fmt.Println(Company())
- // Output: ClearHealthCosts
+ // Output: TransparaGov
}
func ExampleFaker_Company() {
f := New(11)
fmt.Println(f.Company())
- // Output: ClearHealthCosts
+ // Output: TransparaGov
}
func BenchmarkCompany(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Company()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Company()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Company()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Company()
+ }
}
func TestCompany(t *testing.T) {
@@ -64,140 +46,68 @@ func ExampleFaker_CompanySuffix() {
}
func BenchmarkCompanySuffix(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- CompanySuffix()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.CompanySuffix()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.CompanySuffix()
- }
- })
+ for i := 0; i < b.N; i++ {
+ CompanySuffix()
+ }
}
func ExampleBlurb() {
Seed(11)
fmt.Println(Blurb())
- // Output: Motivation
+ // Output: Teamwork
}
func ExampleFaker_Blurb() {
f := New(11)
fmt.Println(f.Blurb())
- // Output: Motivation
+ // Output: Teamwork
}
func BenchmarkBlurb(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Blurb()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Blurb()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Blurb()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Blurb()
+ }
}
func ExampleBuzzWord() {
Seed(11)
fmt.Println(BuzzWord())
- // Output: disintermediate
+ // Output: open system
}
func ExampleFaker_BuzzWord() {
f := New(11)
fmt.Println(f.BuzzWord())
- // Output: disintermediate
+ // Output: open system
}
func BenchmarkBuzzWord(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BuzzWord()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BuzzWord()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BuzzWord()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BuzzWord()
+ }
}
func ExampleBS() {
Seed(11)
fmt.Println(BS())
- // Output: front-end
+ // Output: models
}
func ExampleFaker_BS() {
f := New(11)
fmt.Println(f.BS())
- // Output: front-end
+ // Output: models
}
func BenchmarkBS(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- BS()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.BS()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.BS()
- }
- })
+ for i := 0; i < b.N; i++ {
+ BS()
+ }
}
func ExampleJob() {
@@ -208,10 +118,10 @@ func ExampleJob() {
fmt.Println(jobInfo.Descriptor)
fmt.Println(jobInfo.Level)
- // Output: ClearHealthCosts
- // Agent
- // Future
- // Tactics
+ // Output: TransparaGov
+ // Specialist
+ // Direct
+ // Configuration
}
func ExampleFaker_Job() {
@@ -222,184 +132,94 @@ func ExampleFaker_Job() {
fmt.Println(jobInfo.Descriptor)
fmt.Println(jobInfo.Level)
- // Output: ClearHealthCosts
- // Agent
- // Future
- // Tactics
+ // Output: TransparaGov
+ // Specialist
+ // Direct
+ // Configuration
}
func BenchmarkJob(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Job()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Job()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Job()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Job()
+ }
}
func ExampleJobTitle() {
Seed(11)
fmt.Println(JobTitle())
- // Output: Director
+ // Output: Strategist
}
func ExampleFaker_JobTitle() {
f := New(11)
fmt.Println(f.JobTitle())
- // Output: Director
+ // Output: Strategist
}
func BenchmarkJobTitle(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- JobTitle()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.JobTitle()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.JobTitle()
- }
- })
+ for i := 0; i < b.N; i++ {
+ JobTitle()
+ }
}
func ExampleJobDescriptor() {
Seed(11)
fmt.Println(JobDescriptor())
- // Output: Central
+ // Output: Product
}
func ExampleFaker_JobDescriptor() {
f := New(11)
fmt.Println(f.JobDescriptor())
- // Output: Central
+ // Output: Product
}
func BenchmarkJobDescriptor(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- JobDescriptor()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.JobDescriptor()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.JobDescriptor()
- }
- })
+ for i := 0; i < b.N; i++ {
+ JobDescriptor()
+ }
}
func ExampleJobLevel() {
Seed(11)
fmt.Println(JobLevel())
- // Output: Assurance
+ // Output: Solutions
}
func ExampleFaker_JobLevel() {
f := New(11)
fmt.Println(f.JobLevel())
- // Output: Assurance
+ // Output: Solutions
}
func BenchmarkJobLevel(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- JobLevel()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.JobLevel()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.JobLevel()
- }
- })
+ for i := 0; i < b.N; i++ {
+ JobLevel()
+ }
}
func ExampleSlogan() {
Seed(11)
fmt.Println(Slogan())
- // Output: Universal seamless Focus, interactive.
+ // Output: local area network maximize Drive, mission-critical.
}
func ExampleFaker_Slogan() {
f := New(11)
fmt.Println(f.Slogan())
- // Output: Universal seamless Focus, interactive.
+ // Output: local area network maximize Drive, mission-critical.
}
func BenchmarkSlogan(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Slogan()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Slogan()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Slogan()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Slogan()
+ }
}
diff --git a/csv.go b/csv.go
index 6a2310ef..7f31ec2f 100644
--- a/csv.go
+++ b/csv.go
@@ -6,7 +6,6 @@ import (
"encoding/json"
"errors"
"fmt"
- "math/rand"
"reflect"
"strings"
)
@@ -20,7 +19,7 @@ type CSVOptions struct {
// CSV generates an object or an array of objects in json format
// A nil CSVOptions returns a randomly structured CSV.
-func CSV(co *CSVOptions) ([]byte, error) { return csvFunc(globalFaker, co) }
+func CSV(co *CSVOptions) ([]byte, error) { return csvFunc(GlobalFaker, co) }
// CSV generates an object or an array of objects in json format
// A nil CSVOptions returns a randomly structured CSV.
@@ -84,7 +83,7 @@ func csvFunc(f *Faker, co *CSVOptions) ([]byte, error) {
return nil, errors.New("invalid function, " + field.Function + " does not exist")
}
- value, err := funcInfo.Generate(f.Rand, &field.Params, funcInfo)
+ value, err := funcInfo.Generate(f, &field.Params, funcInfo)
if err != nil {
return nil, err
}
@@ -140,7 +139,7 @@ func addFileCSVLookup() {
{Field: "rowcount", Display: "Row Count", Type: "int", Default: "100", Description: "Number of rows"},
{Field: "fields", Display: "Fields", Type: "[]Field", Description: "Fields containing key name and function"},
},
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
co := CSVOptions{}
delimiter, err := info.GetString(m, "delimiter")
@@ -173,7 +172,6 @@ func addFileCSVLookup() {
}
}
- f := &Faker{Rand: r}
csvOut, err := csvFunc(f, &co)
if err != nil {
return nil, err
diff --git a/csv_test.go b/csv_test.go
index cf7a2116..8dda5350 100644
--- a/csv_test.go
+++ b/csv_test.go
@@ -24,11 +24,10 @@ func ExampleCSV_array() {
fmt.Println(string(value))
- // Output:
- // id,first_name,last_name,password
- // 1,Markus,Moen,856Y5wPZevX9
- // 2,Jalon,Rolfson,64wz4EAS0Hl0
- // 3,Nestor,Harris,14GKq1j7Lx4T
+ // Output: id,first_name,last_name,password
+ // 1,Sonny,Stiedemann,8nwf0o3sBXcR
+ // 2,Verda,Brakus,3beWLpq75Lua
+ // 3,Jules,Cremin,Uu38J14Y8W82
}
func ExampleFaker_CSV_array() {
@@ -49,11 +48,10 @@ func ExampleFaker_CSV_array() {
fmt.Println(string(value))
- // Output:
- // id,first_name,last_name,password
- // 1,Markus,Moen,856Y5wPZevX9
- // 2,Jalon,Rolfson,64wz4EAS0Hl0
- // 3,Nestor,Harris,14GKq1j7Lx4T
+ // Output: id,first_name,last_name,password
+ // 1,Sonny,Stiedemann,8nwf0o3sBXcR
+ // 2,Verda,Brakus,3beWLpq75Lua
+ // 3,Jules,Cremin,Uu38J14Y8W82
}
func TestCSVLookup(t *testing.T) {
@@ -84,7 +82,7 @@ func TestCSVLookup(t *testing.T) {
},
}
- output, err := info.Generate(faker.Rand, &m, info)
+ output, err := info.Generate(faker, &m, info)
if err != nil {
t.Fatal(err.Error())
}
@@ -125,76 +123,7 @@ func BenchmarkCSVLookup100(b *testing.B) {
`{"name":"created_at","function":"date"}`,
},
}
- _, err := info.Generate(faker.Rand, &m, info)
- if err != nil {
- b.Fatal(err.Error())
- }
- }
-}
-
-func BenchmarkCSVLookup1000(b *testing.B) {
- faker := New(0)
-
- for i := 0; i < b.N; i++ {
- info := GetFuncLookup("csv")
- m := MapParams{
- "rowcount": {"1000"},
- "fields": {
- `{"name":"id","function":"autoincrement"}`,
- `{"name":"first_name","function":"firstname"}`,
- `{"name":"last_name","function":"lastname"}`,
- `{"name":"password","function":"password"}`,
- `{"name":"description","function":"paragraph"}`,
- `{"name":"created_at","function":"date"}`,
- },
- }
- _, err := info.Generate(faker.Rand, &m, info)
- if err != nil {
- b.Fatal(err.Error())
- }
- }
-}
-
-func BenchmarkCSVLookup10000(b *testing.B) {
- faker := New(0)
-
- for i := 0; i < b.N; i++ {
- info := GetFuncLookup("csv")
- m := MapParams{
- "rowcount": {"10000"},
- "fields": {
- `{"name":"id","function":"autoincrement"}`,
- `{"name":"first_name","function":"firstname"}`,
- `{"name":"last_name","function":"lastname"}`,
- `{"name":"password","function":"password"}`,
- `{"name":"description","function":"paragraph"}`,
- `{"name":"created_at","function":"date"}`,
- },
- }
- _, err := info.Generate(faker.Rand, &m, info)
- if err != nil {
- b.Fatal(err.Error())
- }
- }
-}
-
-func BenchmarkCSVLookup100000(b *testing.B) {
- faker := New(0)
-
- for i := 0; i < b.N; i++ {
- info := GetFuncLookup("csv")
- m := MapParams{
- "rowcount": {"100000"},
- "fields": {
- `{"name":"id","function":"autoincrement"}`,
- `{"name":"first_name","function":"firstname"}`,
- `{"name":"last_name","function":"lastname"}`,
- `{"name":"password","function":"password"}`,
- `{"name":"description","function":"paragraph"}`,
- `{"name":"created_at","function":"date"}`,
- },
- }
- _, err := info.Generate(faker.Rand, &m, info)
+ _, err := info.Generate(faker, &m, info)
if err != nil {
b.Fatal(err.Error())
}
diff --git a/data/data_test.go b/data/data_test.go
index c28bd110..27d8b0a4 100644
--- a/data/data_test.go
+++ b/data/data_test.go
@@ -27,7 +27,7 @@ func ExampleGet() {
// [Mr. Mrs. Ms. Miss Dr.]
}
-func ExampleGetSub() {
+func ExampleGet_sub() {
// Get data
data := GetSubData("person", "prefix")
diff --git a/data/emoji.go b/data/emoji.go
index b48605ea..8f8ce80f 100644
--- a/data/emoji.go
+++ b/data/emoji.go
@@ -149,7 +149,6 @@ var Emoji = map[string][]string{
"🕳️",
"💣",
"💬",
- "👁️🗨️",
"🗨️",
"🗯️",
"💭",
@@ -415,8 +414,6 @@ var Emoji = map[string][]string{
"🚣♀️",
"🏊",
"⛹️",
- "⛹️♂️",
- "⛹️♀️",
"🏋️",
"🚴",
"🚴♂️",
@@ -449,13 +446,6 @@ var Emoji = map[string][]string{
"👫",
"👬",
"💏",
- "👩❤️💋👨",
- "👨❤️💋👨",
- "👩❤️💋👩",
- "💑",
- "👩❤️👨",
- "👨❤️👨",
- "👩❤️👩",
"👪",
"👨👩👦",
"👨👩👧",
@@ -1479,7 +1469,6 @@ var Emoji = map[string][]string{
"🎌",
"🏴",
"🏳️",
- "🏳️⚧️",
"🏴☠️",
"🇦🇨",
"🇦🇩",
@@ -1739,9 +1728,6 @@ var Emoji = map[string][]string{
"🇿🇦",
"🇿🇲",
"🇿🇼",
- "🏴",
- "🏴",
- "🏴",
},
"description": {
"grinning face",
diff --git a/emoji.go b/emoji.go
index 5eb4372e..c9e9785e 100644
--- a/emoji.go
+++ b/emoji.go
@@ -1,46 +1,44 @@
package gofakeit
-import "math/rand"
-
// Emoji will return a random fun emoji
-func Emoji() string { return emoji(globalFaker.Rand) }
+func Emoji() string { return emoji(GlobalFaker) }
// Emoji will return a random fun emoji
-func (f *Faker) Emoji() string { return emoji(f.Rand) }
+func (f *Faker) Emoji() string { return emoji(f) }
-func emoji(r *rand.Rand) string { return getRandValue(r, []string{"emoji", "emoji"}) }
+func emoji(f *Faker) string { return getRandValue(f, []string{"emoji", "emoji"}) }
// EmojiDescription will return a random fun emoji description
-func EmojiDescription() string { return emojiDescription(globalFaker.Rand) }
+func EmojiDescription() string { return emojiDescription(GlobalFaker) }
// EmojiDescription will return a random fun emoji description
-func (f *Faker) EmojiDescription() string { return emojiDescription(f.Rand) }
+func (f *Faker) EmojiDescription() string { return emojiDescription(f) }
-func emojiDescription(r *rand.Rand) string { return getRandValue(r, []string{"emoji", "description"}) }
+func emojiDescription(f *Faker) string { return getRandValue(f, []string{"emoji", "description"}) }
// EmojiCategory will return a random fun emoji category
-func EmojiCategory() string { return emojiCategory(globalFaker.Rand) }
+func EmojiCategory() string { return emojiCategory(GlobalFaker) }
// EmojiCategory will return a random fun emoji category
-func (f *Faker) EmojiCategory() string { return emojiCategory(f.Rand) }
+func (f *Faker) EmojiCategory() string { return emojiCategory(f) }
-func emojiCategory(r *rand.Rand) string { return getRandValue(r, []string{"emoji", "category"}) }
+func emojiCategory(f *Faker) string { return getRandValue(f, []string{"emoji", "category"}) }
// EmojiAlias will return a random fun emoji alias
-func EmojiAlias() string { return emojiAlias(globalFaker.Rand) }
+func EmojiAlias() string { return emojiAlias(GlobalFaker) }
// EmojiAlias will return a random fun emoji alias
-func (f *Faker) EmojiAlias() string { return emojiAlias(f.Rand) }
+func (f *Faker) EmojiAlias() string { return emojiAlias(f) }
-func emojiAlias(r *rand.Rand) string { return getRandValue(r, []string{"emoji", "alias"}) }
+func emojiAlias(f *Faker) string { return getRandValue(f, []string{"emoji", "alias"}) }
// EmojiTag will return a random fun emoji tag
-func EmojiTag() string { return emojiTag(globalFaker.Rand) }
+func EmojiTag() string { return emojiTag(GlobalFaker) }
// EmojiTag will return a random fun emoji tag
-func (f *Faker) EmojiTag() string { return emojiTag(f.Rand) }
+func (f *Faker) EmojiTag() string { return emojiTag(f) }
-func emojiTag(r *rand.Rand) string { return getRandValue(r, []string{"emoji", "tag"}) }
+func emojiTag(f *Faker) string { return getRandValue(f, []string{"emoji", "tag"}) }
func addEmojiLookup() {
AddFuncLookup("emoji", Info{
@@ -49,8 +47,8 @@ func addEmojiLookup() {
Description: "Digital symbol expressing feelings or ideas in text messages and online chats",
Example: "🤣",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return emoji(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return emoji(f), nil
},
})
@@ -60,8 +58,8 @@ func addEmojiLookup() {
Description: "Brief explanation of the meaning or emotion conveyed by an emoji",
Example: "face vomiting",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return emojiDescription(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return emojiDescription(f), nil
},
})
@@ -71,8 +69,8 @@ func addEmojiLookup() {
Description: "Group or classification of emojis based on their common theme or use, like 'smileys' or 'animals'",
Example: "Smileys & Emotion",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return emojiCategory(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return emojiCategory(f), nil
},
})
@@ -82,8 +80,8 @@ func addEmojiLookup() {
Description: "Alternative name or keyword used to represent a specific emoji in text or code",
Example: "smile",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return emojiAlias(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return emojiAlias(f), nil
},
})
@@ -93,8 +91,8 @@ func addEmojiLookup() {
Description: "Label or keyword associated with an emoji to categorize or search for it easily",
Example: "happy",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return emojiTag(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return emojiTag(f), nil
},
})
}
diff --git a/emoji_test.go b/emoji_test.go
index 0fa6c977..2de91dca 100644
--- a/emoji_test.go
+++ b/emoji_test.go
@@ -9,188 +9,98 @@ func ExampleEmoji() {
Seed(11)
fmt.Println(Emoji())
- // Output: 🧛
+ // Output: 🇫🇴
}
func ExampleFaker_Emoji() {
f := New(11)
fmt.Println(f.Emoji())
- // Output: 🧛
+ // Output: 🇫🇴
}
func BenchmarkEmoji(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Emoji()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Emoji()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Emoji()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Emoji()
+ }
}
func ExampleEmojiDescription() {
Seed(11)
fmt.Println(EmojiDescription())
- // Output: confetti ball
+ // Output: flag: European Union
}
func ExampleFaker_EmojiDescription() {
f := New(11)
fmt.Println(f.EmojiDescription())
- // Output: confetti ball
+ // Output: flag: European Union
}
func BenchmarkEmojiDescription(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- EmojiDescription()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.EmojiDescription()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.EmojiDescription()
- }
- })
+ for i := 0; i < b.N; i++ {
+ EmojiDescription()
+ }
}
func ExampleEmojiCategory() {
Seed(11)
fmt.Println(EmojiCategory())
- // Output: Food & Drink
+ // Output: Flags
}
func ExampleFaker_EmojiCategory() {
f := New(11)
fmt.Println(f.EmojiCategory())
- // Output: Food & Drink
+ // Output: Flags
}
func BenchmarkEmojiCategory(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- EmojiCategory()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.EmojiCategory()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.EmojiCategory()
- }
- })
+ for i := 0; i < b.N; i++ {
+ EmojiCategory()
+ }
}
func ExampleEmojiAlias() {
Seed(11)
fmt.Println(EmojiAlias())
- // Output: deaf_person
+ // Output: eritrea
}
func ExampleFaker_EmojiAlias() {
f := New(11)
fmt.Println(f.EmojiAlias())
- // Output: deaf_person
+ // Output: eritrea
}
func BenchmarkEmojiAlias(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- EmojiAlias()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.EmojiAlias()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.EmojiAlias()
- }
- })
+ for i := 0; i < b.N; i++ {
+ EmojiAlias()
+ }
}
func ExampleEmojiTag() {
Seed(11)
fmt.Println(EmojiTag())
- // Output: strong
+ // Output: toilet
}
func ExampleFaker_EmojiTag() {
f := New(11)
fmt.Println(f.EmojiTag())
- // Output: strong
+ // Output: toilet
}
func BenchmarkEmojiTag(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- EmojiTag()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.EmojiTag()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.EmojiTag()
- }
- })
+ for i := 0; i < b.N; i++ {
+ EmojiTag()
+ }
}
diff --git a/error.go b/error.go
index b31d7725..f2882099 100644
--- a/error.go
+++ b/error.go
@@ -2,133 +2,132 @@ package gofakeit
import (
"errors"
- "math/rand"
)
// Error will return a random generic error
func Error() error {
- return err(globalFaker.Rand)
+ return err(GlobalFaker)
}
// Error will return a random generic error
func (f *Faker) Error() error {
- return err(f.Rand)
+ return err(f)
}
-func err(r *rand.Rand) error {
- return errors.New(generate(r, getRandValue(r, []string{"error", "generic"})))
+func err(f *Faker) error {
+ return errors.New(generate(f, getRandValue(f, []string{"error", "generic"})))
}
// ErrorObject will return a random error object word
func ErrorObject() error {
- return errorObject(globalFaker.Rand)
+ return errorObject(GlobalFaker)
}
// ErrorObject will return a random error object word
func (f *Faker) ErrorObject() error {
- return errorObject(f.Rand)
+ return errorObject(f)
}
-func errorObject(r *rand.Rand) error {
- return errors.New(generate(r, getRandValue(r, []string{"error", "object"})))
+func errorObject(f *Faker) error {
+ return errors.New(generate(f, getRandValue(f, []string{"error", "object"})))
}
// ErrorDatabase will return a random database error
func ErrorDatabase() error {
- return errorDatabase(globalFaker.Rand)
+ return errorDatabase(GlobalFaker)
}
// ErrorDatabase will return a random database error
func (f *Faker) ErrorDatabase() error {
- return errorDatabase(f.Rand)
+ return errorDatabase(f)
}
-func errorDatabase(r *rand.Rand) error {
- return errors.New(generate(r, getRandValue(r, []string{"error", "database"})))
+func errorDatabase(f *Faker) error {
+ return errors.New(generate(f, getRandValue(f, []string{"error", "database"})))
}
// ErrorGRPC will return a random gRPC error
func ErrorGRPC() error {
- return errorGRPC(globalFaker.Rand)
+ return errorGRPC(GlobalFaker)
}
// ErrorGRPC will return a random gRPC error
func (f *Faker) ErrorGRPC() error {
- return errorGRPC(f.Rand)
+ return errorGRPC(f)
}
-func errorGRPC(r *rand.Rand) error {
- return errors.New(generate(r, getRandValue(r, []string{"error", "grpc"})))
+func errorGRPC(f *Faker) error {
+ return errors.New(generate(f, getRandValue(f, []string{"error", "grpc"})))
}
// ErrorHTTP will return a random HTTP error
func ErrorHTTP() error {
- return errorHTTP(globalFaker.Rand)
+ return errorHTTP(GlobalFaker)
}
// ErrorHTTP will return a random HTTP error
func (f *Faker) ErrorHTTP() error {
- return errorHTTP(f.Rand)
+ return errorHTTP(f)
}
-func errorHTTP(r *rand.Rand) error {
- return errors.New(generate(r, getRandValue(r, []string{"error", "http"})))
+func errorHTTP(f *Faker) error {
+ return errors.New(generate(f, getRandValue(f, []string{"error", "http"})))
}
// ErrorHTTPClient will return a random HTTP client error response (400-418)
func ErrorHTTPClient() error {
- return errorHTTPClient(globalFaker.Rand)
+ return errorHTTPClient(GlobalFaker)
}
// ErrorHTTPClient will return a random HTTP client error response (400-418)
func (f *Faker) ErrorHTTPClient() error {
- return errorHTTPClient(f.Rand)
+ return errorHTTPClient(f)
}
-func errorHTTPClient(r *rand.Rand) error {
- return errors.New(generate(r, getRandValue(r, []string{"error", "http_client"})))
+func errorHTTPClient(f *Faker) error {
+ return errors.New(generate(f, getRandValue(f, []string{"error", "http_client"})))
}
// ErrorHTTPServer will return a random HTTP server error response (500-511)
func ErrorHTTPServer() error {
- return errorHTTPServer(globalFaker.Rand)
+ return errorHTTPServer(GlobalFaker)
}
// ErrorHTTPServer will return a random HTTP server error response (500-511)
func (f *Faker) ErrorHTTPServer() error {
- return errorHTTPServer(f.Rand)
+ return errorHTTPServer(f)
}
-func errorHTTPServer(r *rand.Rand) error {
- return errors.New(generate(r, getRandValue(r, []string{"error", "http_server"})))
+func errorHTTPServer(f *Faker) error {
+ return errors.New(generate(f, getRandValue(f, []string{"error", "http_server"})))
}
// ErrorRuntime will return a random runtime error
func ErrorRuntime() error {
- return errorRuntime(globalFaker.Rand)
+ return errorRuntime(GlobalFaker)
}
// ErrorRuntime will return a random runtime error
func (f *Faker) ErrorRuntime() error {
- return errorRuntime(f.Rand)
+ return errorRuntime(f)
}
-func errorRuntime(r *rand.Rand) error {
- return errors.New(generate(r, getRandValue(r, []string{"error", "runtime"})))
+func errorRuntime(f *Faker) error {
+ return errors.New(generate(f, getRandValue(f, []string{"error", "runtime"})))
}
// ErrorValidation will return a random validation error
func ErrorValidation() error {
- return errorValidation(globalFaker.Rand)
+ return errorValidation(GlobalFaker)
}
// ErrorValidation will return a random validation error
func (f *Faker) ErrorValidation() error {
- return errorValidation(f.Rand)
+ return errorValidation(f)
}
-func errorValidation(r *rand.Rand) error {
- return errors.New(generate(r, getRandValue(r, []string{"error", "validation"})))
+func errorValidation(f *Faker) error {
+ return errors.New(generate(f, getRandValue(f, []string{"error", "validation"})))
}
func addErrorLookup() {
@@ -138,8 +137,8 @@ func addErrorLookup() {
Description: "Message displayed by a computer or software when a problem or mistake is encountered",
Example: "syntax error",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return err(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return err(f), nil
},
})
@@ -149,8 +148,8 @@ func addErrorLookup() {
Description: "Various categories conveying details about encountered errors",
Example: "protocol",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return errorObject(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return errorObject(f), nil
},
})
@@ -160,8 +159,8 @@ func addErrorLookup() {
Description: "A problem or issue encountered while accessing or managing a database",
Example: "sql error",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return errorDatabase(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return errorDatabase(f), nil
},
})
@@ -171,8 +170,8 @@ func addErrorLookup() {
Description: "Communication failure in the high-performance, open-source universal RPC framework",
Example: "client protocol error",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return errorGRPC(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return errorGRPC(f), nil
},
})
@@ -182,8 +181,8 @@ func addErrorLookup() {
Description: "A problem with a web http request",
Example: "invalid method",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return errorHTTP(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return errorHTTP(f), nil
},
})
@@ -193,8 +192,8 @@ func addErrorLookup() {
Description: "Failure or issue occurring within a client software that sends requests to web servers",
Example: "request timeout",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return errorHTTPClient(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return errorHTTPClient(f), nil
},
})
@@ -204,8 +203,8 @@ func addErrorLookup() {
Description: "Failure or issue occurring within a server software that recieves requests from clients",
Example: "internal server error",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return errorHTTPServer(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return errorHTTPServer(f), nil
},
})
@@ -215,8 +214,8 @@ func addErrorLookup() {
Description: "Malfunction occuring during program execution, often causing abrupt termination or unexpected behavior",
Example: "address out of bounds",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return errorRuntime(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return errorRuntime(f), nil
},
})
@@ -226,8 +225,8 @@ func addErrorLookup() {
Description: "Occurs when input data fails to meet required criteria or format specifications",
Example: "missing required field",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return errorValidation(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return errorValidation(f), nil
},
})
}
diff --git a/error_test.go b/error_test.go
index faf51cd6..2cf6d32b 100644
--- a/error_test.go
+++ b/error_test.go
@@ -9,114 +9,60 @@ func ExampleError() {
Seed(11)
fmt.Println(Error())
- // Output: failed to calculate pointer
+ // Output: variable assigned before declaration
}
func ExampleFaker_Error() {
f := New(11)
fmt.Println(f.Error())
- // Output: failed to calculate pointer
+ // Output: variable assigned before declaration
}
func BenchmarkError(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Error()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Error()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Error()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Error()
+ }
}
func ExampleErrorObject() {
Seed(11)
fmt.Println(ErrorObject())
- // Output: argument
+ // Output: url
}
func ExampleFaker_ErrorObject() {
f := New(11)
fmt.Println(f.ErrorObject())
- // Output: argument
+ // Output: url
}
func BenchmarkErrorObject(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- ErrorObject()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.ErrorObject()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.ErrorObject()
- }
- })
+ for i := 0; i < b.N; i++ {
+ ErrorObject()
+ }
}
func ExampleErrorDatabase() {
Seed(11)
fmt.Println(ErrorDatabase())
- // Output: bad connection
+ // Output: destination pointer is nil
}
func ExampleFaker_ErrorDatabase() {
f := New(11)
fmt.Println(f.ErrorDatabase())
- // Output: bad connection
+ // Output: destination pointer is nil
}
func BenchmarkErrorDatabase(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- ErrorDatabase()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.ErrorDatabase()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.ErrorDatabase()
- }
- })
+ for i := 0; i < b.N; i++ {
+ ErrorDatabase()
+ }
}
func ExampleErrorGRPC() {
@@ -134,27 +80,9 @@ func ExampleFaker_ErrorGRPC() {
}
func BenchmarkErrorGRPC(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- ErrorGRPC()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.ErrorGRPC()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.ErrorGRPC()
- }
- })
+ for i := 0; i < b.N; i++ {
+ ErrorGRPC()
+ }
}
func ExampleErrorHTTP() {
@@ -172,177 +100,87 @@ func ExampleFaker_ErrorHTTP() {
}
func BenchmarkErrorHTTP(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- ErrorHTTP()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.ErrorHTTP()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.ErrorHTTP()
- }
- })
+ for i := 0; i < b.N; i++ {
+ ErrorHTTP()
+ }
}
func ExampleErrorHTTPClient() {
Seed(11)
fmt.Println(ErrorHTTPClient())
- // Output: payment required
+ // Output: expectation failed
}
func ExampleFaker_ErrorHTTPClient() {
f := New(11)
fmt.Println(f.ErrorHTTPClient())
- // Output: payment required
+ // Output: expectation failed
}
func BenchmarkErrorHTTPClient(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- ErrorHTTPClient()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.ErrorHTTPClient()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.ErrorHTTPClient()
- }
- })
+ for i := 0; i < b.N; i++ {
+ ErrorHTTPClient()
+ }
}
func ExampleErrorHTTPServer() {
Seed(11)
fmt.Println(ErrorHTTPServer())
- // Output: internal server error
+ // Output: not extended
}
func ExampleFaker_ErrorHTTPServer() {
f := New(11)
fmt.Println(f.ErrorHTTPServer())
- // Output: internal server error
+ // Output: not extended
}
func BenchmarkErrorHTTPServer(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- ErrorHTTPServer()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.ErrorHTTPServer()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.ErrorHTTPServer()
- }
- })
+ for i := 0; i < b.N; i++ {
+ ErrorHTTPServer()
+ }
}
func ExampleErrorRuntime() {
Seed(11)
fmt.Println(ErrorRuntime())
- // Output: panic: runtime error: invalid memory address or nil pointer dereference
+ // Output: expected 2 arguments, got 3
}
func ExampleFaker_ErrorRuntime() {
f := New(11)
fmt.Println(f.ErrorRuntime())
- // Output: panic: runtime error: invalid memory address or nil pointer dereference
+ // Output: expected 2 arguments, got 3
}
func BenchmarkErrorRuntime(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- ErrorRuntime()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.ErrorRuntime()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.ErrorRuntime()
- }
- })
+ for i := 0; i < b.N; i++ {
+ ErrorRuntime()
+ }
}
func ExampleErrorValidation() {
Seed(11)
fmt.Println(ErrorValidation())
- // Output: state max length exceeded
+ // Output: payment details cannot be verified
}
func ExampleFaker_ErrorValidation() {
f := New(11)
fmt.Println(f.ErrorValidation())
- // Output: state max length exceeded
+ // Output: payment details cannot be verified
}
func BenchmarkErrorValidation(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- ErrorValidation()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.ErrorValidation()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.ErrorValidation()
- }
- })
+ for i := 0; i < b.N; i++ {
+ ErrorValidation()
+ }
}
diff --git a/fakeable.go b/fakeable.go
index 1ed5b6fe..01932ec2 100644
--- a/fakeable.go
+++ b/fakeable.go
@@ -15,7 +15,7 @@ type Fakeable interface {
func isFakeable(t reflect.Type) bool {
fakeableTyp := reflect.TypeOf((*Fakeable)(nil)).Elem()
- return t.Implements(fakeableTyp) || reflect.PtrTo(t).Implements(fakeableTyp)
+ return t.Implements(fakeableTyp) || reflect.PointerTo(t).Implements(fakeableTyp)
}
func callFake(faker *Faker, v reflect.Value, possibleKinds ...reflect.Kind) (any, error) {
diff --git a/fakeable_external_test.go b/fakeable_external_test.go
index 13efa17a..da7d5861 100644
--- a/fakeable_external_test.go
+++ b/fakeable_external_test.go
@@ -2,11 +2,10 @@ package gofakeit_test
import (
"fmt"
- "math/rand"
"testing"
"time"
- "github.com/brianvoe/gofakeit/v6"
+ "github.com/brianvoe/gofakeit/v7"
)
var (
@@ -596,7 +595,7 @@ func TestNestedOverrideCustom(t *testing.T) {
Description: "Raw date time.Time object",
},
},
- Generate: func(r *rand.Rand, m *gofakeit.MapParams, info *gofakeit.Info) (any, error) {
+ Generate: func(f *gofakeit.Faker, m *gofakeit.MapParams, info *gofakeit.Info) (any, error) {
return gofakeit.Date(), nil
},
})
@@ -762,7 +761,6 @@ func ExampleEvenInt() {
fmt.Println(E1)
fmt.Println(E2)
- // Output:
- // 6
- // -92
+ // Output: -2
+ // 122
}
diff --git a/fakeable_test.go b/fakeable_test.go
index a353730d..2fbc9aa1 100644
--- a/fakeable_test.go
+++ b/fakeable_test.go
@@ -74,23 +74,23 @@ func ExampleFakeable() {
fmt.Printf("%#v\n", t2)
fmt.Printf("%#v\n", t3)
fmt.Printf("%#v\n", t4)
- // Expected Output:
- // gofakeit.testStruct1{B:"Margarette"}
- // gofakeit.testStruct1{B:"Margarette"}
- // gofakeit.testStruct2{B:"Margarette"}
- // gofakeit.testStruct2{B:"Margarette"}
+
+ // Output: gofakeit.testStruct1{B:"Colton"}
+ // gofakeit.testStruct1{B:"Colton"}
+ // gofakeit.testStruct2{B:"Colton"}
+ // gofakeit.testStruct2{B:"Colton"}
}
type gammaFloat64 float64
-func (gammaFloat64) Fake(faker *Faker) (any, error) {
+func (gammaFloat64) Fake(f *Faker) (any, error) {
alpha := 2.0
// Generate a random value from the Gamma distribution
var r float64
for r == 0 {
- u := faker.Float64Range(0, 1)
- v := faker.Float64Range(0, 1)
+ u := f.Float64Range(0, 1)
+ v := f.Float64Range(0, 1)
w := u * (1 - u)
y := math.Sqrt(-2 * math.Log(w) / w)
x := alpha * (y*v + u - 0.5)
@@ -101,7 +101,7 @@ func (gammaFloat64) Fake(faker *Faker) (any, error) {
return gammaFloat64(r), nil
}
-func ExampleGammaFloat64() {
+func ExampleFakeable_gammaFloat64() {
f1 := New(100)
// Fakes random values from the Gamma distribution
@@ -116,10 +116,9 @@ func ExampleGammaFloat64() {
fmt.Println(A2)
fmt.Println(A3)
- // Output:
- // 10.300651760129734
- // 5.391434877284098
- // 2.0575989252140676
+ // Output: 1.9058272589164647
+ // 1.951453943304136
+ // 4.336093466276675
}
type poissonInt64 int64
@@ -139,18 +138,18 @@ func (poissonInt64) Fake(faker *Faker) (any, error) {
return poissonInt64(k - 1), nil
}
-type customerSupportEmployee struct {
+type employee struct {
Name string `fake:"{firstname} {lastname}"`
CallCountPerHour poissonInt64
}
-func ExamplecustomerSupportEmployee() {
+func ExampleFakeable_employee() {
f1 := New(100)
// Fakes random values from the Gamma distribution
- var A1 customerSupportEmployee
- var A2 customerSupportEmployee
- var A3 customerSupportEmployee
+ var A1 employee
+ var A2 employee
+ var A3 employee
f1.Struct(&A1)
f1.Struct(&A2)
f1.Struct(&A3)
@@ -159,8 +158,7 @@ func ExamplecustomerSupportEmployee() {
fmt.Printf("%#v\n", A2)
fmt.Printf("%#v\n", A3)
- // Output:
- // gofakeit.customerSupportEmployee{Name:"Pearline Rippin", CallCountPerHour:12}
- // gofakeit.customerSupportEmployee{Name:"Sammie Renner", CallCountPerHour:23}
- // gofakeit.customerSupportEmployee{Name:"Katlyn Runte", CallCountPerHour:8}
+ // Output: gofakeit.employee{Name:"Madelynn Hickle", CallCountPerHour:17}
+ // gofakeit.employee{Name:"Brooke Berge", CallCountPerHour:8}
+ // gofakeit.employee{Name:"Rosalee Roberts", CallCountPerHour:10}
}
diff --git a/faker.go b/faker.go
index 715c67ca..ac0cf85b 100644
--- a/faker.go
+++ b/faker.go
@@ -1,103 +1,106 @@
package gofakeit
import (
- crand "crypto/rand"
- "encoding/binary"
- "math/rand"
+ "errors"
+ "math/rand/v2"
+ "reflect"
"sync"
+
+ "github.com/brianvoe/gofakeit/v7/source"
)
-// Create global variable to deal with global function call.
-var globalFaker *Faker = New(0)
+// Create global variable to deal with global function call
+var GlobalFaker *Faker = New(0)
-// Faker struct is the primary struct for using localized.
+// Faker struct is the primary struct for using localized
type Faker struct {
- Rand *rand.Rand
-}
-
-type lockedSource struct {
- lk sync.Mutex
- src rand.Source64
-}
-
-func (r *lockedSource) Int63() (n int64) {
- r.lk.Lock()
- n = r.src.Int63()
- r.lk.Unlock()
+ Rand rand.Source
- return
+ // Lock to make thread safe
+ Locked bool
+ mu sync.Mutex
}
-func (r *lockedSource) Uint64() (n uint64) {
- r.lk.Lock()
- n = r.src.Uint64()
- r.lk.Unlock()
- return
-}
-
-func (r *lockedSource) Seed(seed int64) {
- r.lk.Lock()
- r.src.Seed(seed)
- r.lk.Unlock()
+// New creates and returns a new Faker struct seeded with a given seed
+// using the PCG algorithm in lock mode for thread safety
+func New(seed uint64) *Faker {
+ return &Faker{
+ Rand: rand.NewPCG(seed, seed),
+ Locked: true,
+ }
}
-type cryptoRand struct {
- sync.Mutex
- buf []byte
+// NewFaker takes in a rand.Source and thread lock state and returns a new Faker struct
+func NewFaker(src rand.Source, lock bool) *Faker {
+ return &Faker{
+ Rand: src,
+ Locked: lock,
+ }
}
-func (c *cryptoRand) Seed(seed int64) {}
+// Seed attempts to seed the Faker with the given seed
+func (f *Faker) Seed(args ...any) error {
+ // Lock if locked
+ if f.Locked {
+ f.mu.Lock()
+ defer f.mu.Unlock()
+ }
-func (c *cryptoRand) Uint64() uint64 {
- // Lock to make reading thread safe
- c.Lock()
- defer c.Unlock()
+ // Ensure GlobalFaker is not nil and Rand is initialized
+ if GlobalFaker == nil || GlobalFaker.Rand == nil {
+ return errors.New("GlobalFaker or GlobalFaker.Rand is nil")
+ }
- crand.Read(c.buf)
- return binary.BigEndian.Uint64(c.buf)
-}
+ // If args is empty or 0, seed with a random crypto seed
+ if len(args) == 0 {
+ faker := NewFaker(source.NewCrypto(), false)
+ args = append(args, faker.Uint64())
+ }
-func (c *cryptoRand) Int63() int64 {
- return int64(c.Uint64() & ^uint64(1<<63))
-}
+ if args[0] == 0 {
+ faker := NewFaker(source.NewCrypto(), false)
+ args[0] = faker.Uint64()
+ }
-// New will utilize math/rand for concurrent random usage.
-// Setting seed to 0 will use crypto/rand for the initial seed number.
-func New(seed int64) *Faker {
- // If passing 0 create crypto safe int64 for initial seed number
- if seed == 0 {
- binary.Read(crand.Reader, binary.BigEndian, &seed)
+ // Retrieve the Seed method
+ method := reflect.ValueOf(GlobalFaker.Rand).MethodByName("Seed")
+ if !method.IsValid() {
+ return errors.New("Seed method not found")
}
- return &Faker{Rand: rand.New(&lockedSource{src: rand.NewSource(seed).(rand.Source64)})}
-}
+ // Adjust args if method requires exactly 2 args but only 1 was provided
+ if method.Type().NumIn() == 2 && len(args) == 1 {
+ args = append(args, args[0]) // Duplicate the first value if only one is provided
+ }
-// NewUnlocked will utilize math/rand for non concurrent safe random usage.
-// Setting seed to 0 will use crypto/rand for the initial seed number.
-// NewUnlocked is more performant but not safe to run concurrently.
-func NewUnlocked(seed int64) *Faker {
- // If passing 0 create crypto safe int64 for initial seed number
- if seed == 0 {
- binary.Read(crand.Reader, binary.BigEndian, &seed)
+ // Get array of function argument types and prepare converted arguments
+ argTypes := make([]reflect.Type, method.Type().NumIn())
+ convertedArgs := make([]reflect.Value, len(args))
+ for i := 0; i < method.Type().NumIn(); i++ {
+ argTypes[i] = method.Type().In(i)
}
- return &Faker{Rand: rand.New(rand.NewSource(seed))}
-}
+ // Convert args to the expected type by the Seed method
+ for i, arg := range args {
+ if i < len(argTypes) { // Ensure arg index is within argTypes bounds
+ argValue := reflect.ValueOf(arg)
+ // Check if conversion is necessary
+ if argValue.Type().ConvertibleTo(argTypes[i]) {
+ convertedArgs[i] = argValue.Convert(argTypes[i])
+ } else {
+ // If not convertible, use the argument as is (reflectively)
+ convertedArgs[i] = argValue
+ }
+ }
+ }
-// NewCrypto will utilize crypto/rand for concurrent random usage.
-func NewCrypto() *Faker {
- return &Faker{Rand: rand.New(&cryptoRand{
- buf: make([]byte, 8),
- })}
-}
+ // Dynamically call the Seed method with converted arguments
+ method.Call(convertedArgs)
-// NewCustom will utilize a custom rand.Source64 for concurrent random usage
-// See https://golang.org/src/math/rand/rand.go for required interface methods
-func NewCustom(source rand.Source64) *Faker {
- return &Faker{Rand: rand.New(source)}
+ return nil
}
-// SetGlobalFaker will allow you to set what type of faker is globally used. Defailt is math/rand
-func SetGlobalFaker(faker *Faker) {
- globalFaker = faker
+// Seed attempts to seed the GlobalFaker with the given seed
+func Seed(args ...any) error {
+ return GlobalFaker.Seed(args...)
}
diff --git a/faker_test.go b/faker_test.go
index c64f00b3..6b5c191f 100644
--- a/faker_test.go
+++ b/faker_test.go
@@ -2,12 +2,14 @@ package gofakeit
import (
"fmt"
+ "math/rand/v2"
"sync"
"testing"
)
func Example() {
Seed(11)
+
fmt.Println("Name:", Name())
fmt.Println("Email:", Email())
fmt.Println("Phone:", Phone())
@@ -21,23 +23,22 @@ func Example() {
fmt.Println("Job Title:", JobTitle())
fmt.Println("Password:", Password(true, true, true, true, false, 32))
- // Output:
- // Name: Markus Moen
- // Email: alaynawuckert@kozey.biz
- // Phone: 9948995369
- // Address: 35300 South Roadshaven, Miami, Tennessee 58302
- // BS: streamline
- // Beer Name: Pliny The Elder
- // Color: Gray
- // Company: Center for Responsive Politics
- // Credit Card: 3821714800889989
- // Hacker Phrase: Overriding the capacitor won't do anything, we need to compress the online SMTP protocol!
- // Job Title: Supervisor
- // Password: #8L79W6s4E9jT2Q047??YkyD0xxnC2#u
+ // Output: Name: Sonny Stiedemann
+ // Email: codydonnelly@leannon.biz
+ // Phone: 7598907999
+ // Address: 4737 Port Hillstown, Santa Ana, Alabama 41026
+ // BS: enable
+ // Beer Name: Chocolate St
+ // Color: Turquoise
+ // Company: Boundless
+ // Credit Card: 6282690620525711
+ // Hacker Phrase: Try to bundle the PNG firewall, maybe it will deconstruct the open-source bandwidth!
+ // Job Title: Assistant
+ // Password: Nyf8p8ka1Kvgn**@3H&$w7j01yM1vkc2
}
func ExampleNew() {
- // Create new pseudo random faker struct and set initial seed
+ // Get new faker with default settings
fake := New(11)
// All global functions are also available in the structs methods
@@ -46,101 +47,60 @@ func ExampleNew() {
fmt.Println("Phone:", fake.Phone())
// Output:
- // Name: Markus Moen
- // Email: alaynawuckert@kozey.biz
- // Phone: 9948995369
+ // Name: Sonny Stiedemann
+ // Email: codydonnelly@leannon.biz
+ // Phone: 7598907999
}
-func ExampleNewUnlocked() {
- fake := NewUnlocked(11)
+func ExampleNewFaker() {
+ // Create new faker with ChaCha8, cryptographically secure
+ chacha := rand.NewChaCha8([32]byte{5, 4, 3, 2, 1, 0})
+ fake := NewFaker(chacha, true)
- // All global functions are also available in the structs methods
- fmt.Println("Name:", fake.Name())
- fmt.Println("Email:", fake.Email())
- fmt.Println("Phone:", fake.Phone())
+ // or
- // Output:
- // Name: Markus Moen
- // Email: alaynawuckert@kozey.biz
- // Phone: 9948995369
-}
+ // Create new faker with PCG, pseudo-random
+ pcg := rand.NewPCG(0, 0)
+ fake = NewFaker(pcg, false)
-func TestNewUnlocked(t *testing.T) {
- fake := NewUnlocked(0)
- if fake.Name() == "" {
- t.Error("Name was empty")
- }
-}
-
-func ExampleNewCrypto() {
- // Create new crypto faker struct
- fake := NewCrypto()
-
- // All global functions are also available in the structs methods
fmt.Println("Name:", fake.Name())
- fmt.Println("Email:", fake.Email())
- fmt.Println("Phone:", fake.Phone())
- // Cannot output example as crypto/rand cant be predicted
+ // Output:
+ // Name: Damian Pagac
}
-func TestNewCrypto(t *testing.T) {
- // Create new crypto faker struct
- fake := NewCrypto()
+func TestSeed(t *testing.T) {
+ // Test crypto that has no parameters in Seed
+ GlobalFaker = New(11)
- // All global functions are also available in the structs methods
- name := fake.Name()
- email := fake.Email()
- phone := fake.Phone()
+ // Test a simple function
+ name := Name()
- if name == "" || email == "" || phone == "" {
- t.Error("One of the values was empty")
+ // Seed
+ err := Seed(11)
+ if err != nil {
+ t.Error(err)
}
-}
-
-type customRand struct{}
-
-func (c *customRand) Seed(seed int64) {}
-func (c *customRand) Uint64() uint64 { return 8675309 }
-func (c *customRand) Int63() int64 { return int64(c.Uint64() & ^uint64(1<<63)) }
-
-func ExampleNewCustom() {
- // Setup stuct and methods required to meet interface needs
- // type customRand struct {}
- // func (c *customRand) Seed(seed int64) {}
- // func (c *customRand) Uint64() uint64 { return 8675309 }
- // func (c *customRand) Int63() int64 { return int64(c.Uint64() & ^uint64(1<<63)) }
-
- // Create new custom faker struct
- fake := NewCustom(&customRand{})
-
- // All global functions are also available in the structs methods
- fmt.Println("Name:", fake.Name())
- fmt.Println("Email:", fake.Email())
- fmt.Println("Phone:", fake.Phone())
- // Output:
- // Name: Aaliyah Abbott
- // Email: aaliyahabbott@abbott.com
- // Phone: 1000000000
-}
-
-func ExampleSetGlobalFaker() {
- cryptoFaker := NewCrypto()
- SetGlobalFaker(cryptoFaker)
+ // Make sure name is the same
+ if name != Name() {
+ t.Error("Name was different after seed")
+ }
}
func TestSetGlobalFaker(t *testing.T) {
- cryptoFaker := NewCrypto()
- SetGlobalFaker(cryptoFaker)
+ // Set global to crypto
+ crypto := rand.NewPCG(11, 11)
+ GlobalFaker = NewFaker(crypto, true)
+ // Test a simple function
name := Name()
if name == "" {
t.Error("Name was empty")
}
- // Set global back to psuedo
- SetGlobalFaker(New(0))
+ // Set global back to default
+ GlobalFaker = New(0)
}
func TestConcurrency(t *testing.T) {
@@ -148,7 +108,7 @@ func TestConcurrency(t *testing.T) {
setupComplete.Add(1)
var wg sync.WaitGroup
- for i := 0; i < 10000; i++ {
+ for i := 0; i < 1000; i++ {
wg.Add(1)
go func() {
setupComplete.Wait()
diff --git a/file.go b/file.go
index 3812021e..ffefe863 100644
--- a/file.go
+++ b/file.go
@@ -1,22 +1,20 @@
package gofakeit
-import "math/rand"
-
// FileExtension will generate a random file extension
-func FileExtension() string { return fileExtension(globalFaker.Rand) }
+func FileExtension() string { return fileExtension(GlobalFaker) }
// FileExtension will generate a random file extension
-func (f *Faker) FileExtension() string { return fileExtension(f.Rand) }
+func (f *Faker) FileExtension() string { return fileExtension(f) }
-func fileExtension(r *rand.Rand) string { return getRandValue(r, []string{"file", "extension"}) }
+func fileExtension(f *Faker) string { return getRandValue(f, []string{"file", "extension"}) }
// FileMimeType will generate a random mime file type
-func FileMimeType() string { return fileMimeType(globalFaker.Rand) }
+func FileMimeType() string { return fileMimeType(GlobalFaker) }
// FileMimeType will generate a random mime file type
-func (f *Faker) FileMimeType() string { return fileMimeType(f.Rand) }
+func (f *Faker) FileMimeType() string { return fileMimeType(f) }
-func fileMimeType(r *rand.Rand) string { return getRandValue(r, []string{"file", "mime_type"}) }
+func fileMimeType(f *Faker) string { return getRandValue(f, []string{"file", "mime_type"}) }
func addFileLookup() {
AddFuncLookup("fileextension", Info{
@@ -25,8 +23,8 @@ func addFileLookup() {
Description: "Suffix appended to a filename indicating its format or type",
Example: "nes",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return fileExtension(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return fileExtension(f), nil
},
})
@@ -36,8 +34,8 @@ func addFileLookup() {
Description: "Defines file format and nature for browsers and email clients using standardized identifiers",
Example: "application/json",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return fileMimeType(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return fileMimeType(f), nil
},
})
}
diff --git a/file_test.go b/file_test.go
index 08c5faef..8b239a59 100644
--- a/file_test.go
+++ b/file_test.go
@@ -9,74 +9,38 @@ func ExampleFileMimeType() {
Seed(11)
fmt.Println(FileMimeType())
- // Output: application/dsptype
+ // Output: application/x-wri
}
func ExampleFaker_FileMimeType() {
f := New(11)
fmt.Println(f.FileMimeType())
- // Output: application/dsptype
+ // Output: application/x-wri
}
func BenchmarkFileMimeType(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- FileMimeType()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.FileMimeType()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.FileMimeType()
- }
- })
+ for i := 0; i < b.N; i++ {
+ FileMimeType()
+ }
}
func ExampleFileExtension() {
Seed(11)
fmt.Println(FileExtension())
- // Output: nes
+ // Output: dtd
}
func ExampleFaker_FileExtension() {
f := New(11)
fmt.Println(f.FileExtension())
- // Output: nes
+ // Output: dtd
}
func BenchmarkFileExtension(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- FileExtension()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.FileExtension()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.FileExtension()
- }
- })
+ for i := 0; i < b.N; i++ {
+ FileExtension()
+ }
}
diff --git a/finance.go b/finance.go
index a46907a6..4e363326 100644
--- a/finance.go
+++ b/finance.go
@@ -1,7 +1,6 @@
package gofakeit
import (
- "math/rand"
"strconv"
"unicode"
)
@@ -10,17 +9,17 @@ const cusipStr = upperStr + numericStr
// CUSIP
func Cusip() string {
- return cusip(globalFaker.Rand)
+ return cusip(GlobalFaker)
}
func (f *Faker) Cusip() string {
- return cusip(f.Rand)
+ return cusip(f)
}
-func cusip(r *rand.Rand) string {
+func cusip(f *Faker) string {
cusipBytes := make([]byte, 8)
for i := 0; i < len(cusipBytes); i++ {
- cusipBytes[i] = byte(cusipStr[r.Intn(len(cusipStr))])
+ cusipBytes[i] = byte(cusipStr[f.IntN(len(cusipStr))])
}
baseCusip := string(cusipBytes)
@@ -31,16 +30,16 @@ func cusip(r *rand.Rand) string {
// ISIN
func Isin() string {
- return isin(globalFaker.Rand)
+ return isin(GlobalFaker)
}
func (f *Faker) Isin() string {
- return isin(f.Rand)
+ return isin(f)
}
-func isin(r *rand.Rand) string {
- countryCode := CountryAbr()
- nsin := cusip(r)
+func isin(f *Faker) string {
+ countryCode := countryAbr(f)
+ nsin := cusip(f)
isinChkDig := isinChecksumDigit(countryCode + nsin)
return countryCode + nsin + isinChkDig
}
@@ -111,8 +110,8 @@ func addFinanceLookup() {
Description: "Unique identifier for securities, especially bonds, in the United States and Canada",
Example: "38259P508",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return cusip(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return cusip(f), nil
},
})
AddFuncLookup("isin", Info{
@@ -121,8 +120,8 @@ func addFinanceLookup() {
Description: "International standard code for uniquely identifying securities worldwide",
Example: "CVLRQCZBXQ97",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return isin(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return isin(f), nil
},
})
}
diff --git a/finance_test.go b/finance_test.go
index 9a7442bf..b824c9d7 100644
--- a/finance_test.go
+++ b/finance_test.go
@@ -10,14 +10,14 @@ func ExampleCusip() {
Seed(11)
fmt.Println(Cusip())
- // Output: MLRQCZBX0
+ // Output: 64HHTI0T8
}
func ExampleFaker_Cusip() {
f := New(11)
fmt.Println(f.Cusip())
- // Output: MLRQCZBX0
+ // Output: 64HHTI0T8
}
func TestCusip(t *testing.T) {
@@ -54,27 +54,9 @@ func TestCusipCheckDigit(t *testing.T) {
}
func BenchmarkCusip(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Cusip()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Cusip()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Cusip()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Cusip()
+ }
}
// ISIN Tests
@@ -82,14 +64,14 @@ func ExampleIsin() {
Seed(11)
fmt.Println(Isin())
- // Output: CVLRQCZBXQ97
+ // Output: TO4HHTI0T819
}
func ExampleFaker_Isin() {
f := New(11)
fmt.Println(f.Isin())
- // Output: AMMLRQCZBX03
+ // Output: TO4HHTI0T819
}
func TestIsin(t *testing.T) {
@@ -126,25 +108,7 @@ func TestIsinCheckDigit(t *testing.T) {
}
func BenchmarkIsin(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Isin()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Isin()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Isin()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Isin()
+ }
}
diff --git a/food.go b/food.go
index ae1bb2fd..111dbc25 100644
--- a/food.go
+++ b/food.go
@@ -1,89 +1,88 @@
package gofakeit
import (
- "math/rand"
"strings"
)
// Fruit will return a random fruit name
-func Fruit() string { return fruit(globalFaker.Rand) }
+func Fruit() string { return fruit(GlobalFaker) }
// Fruit will return a random fruit name
-func (f *Faker) Fruit() string { return fruit(f.Rand) }
+func (f *Faker) Fruit() string { return fruit(f) }
-func fruit(r *rand.Rand) string { return getRandValue(r, []string{"food", "fruit"}) }
+func fruit(f *Faker) string { return getRandValue(f, []string{"food", "fruit"}) }
// Vegetable will return a random vegetable name
-func Vegetable() string { return vegetable(globalFaker.Rand) }
+func Vegetable() string { return vegetable(GlobalFaker) }
// Vegetable will return a random vegetable name
-func (f *Faker) Vegetable() string { return vegetable(f.Rand) }
+func (f *Faker) Vegetable() string { return vegetable(f) }
-func vegetable(r *rand.Rand) string { return getRandValue(r, []string{"food", "vegetable"}) }
+func vegetable(f *Faker) string { return getRandValue(f, []string{"food", "vegetable"}) }
// Breakfast will return a random breakfast name
-func Breakfast() string { return breakfast(globalFaker.Rand) }
+func Breakfast() string { return breakfast(GlobalFaker) }
// Breakfast will return a random breakfast name
-func (f *Faker) Breakfast() string { return breakfast(f.Rand) }
+func (f *Faker) Breakfast() string { return breakfast(f) }
-func breakfast(r *rand.Rand) string {
- v := getRandValue(r, []string{"food", "breakfast"})
+func breakfast(f *Faker) string {
+ v := getRandValue(f, []string{"food", "breakfast"})
return strings.ToUpper(v[:1]) + v[1:]
}
// Lunch will return a random lunch name
-func Lunch() string { return lunch(globalFaker.Rand) }
+func Lunch() string { return lunch(GlobalFaker) }
// Lunch will return a random lunch name
-func (f *Faker) Lunch() string { return lunch(f.Rand) }
+func (f *Faker) Lunch() string { return lunch(f) }
-func lunch(r *rand.Rand) string {
- v := getRandValue(r, []string{"food", "lunch"})
+func lunch(f *Faker) string {
+ v := getRandValue(f, []string{"food", "lunch"})
return strings.ToUpper(v[:1]) + v[1:]
}
// Dinner will return a random dinner name
-func Dinner() string { return dinner(globalFaker.Rand) }
+func Dinner() string { return dinner(GlobalFaker) }
// Dinner will return a random dinner name
-func (f *Faker) Dinner() string { return dinner(f.Rand) }
+func (f *Faker) Dinner() string { return dinner(f) }
-func dinner(r *rand.Rand) string {
- v := getRandValue(r, []string{"food", "dinner"})
+func dinner(f *Faker) string {
+ v := getRandValue(f, []string{"food", "dinner"})
return strings.ToUpper(v[:1]) + v[1:]
}
// Drink will return a random drink name
-func Drink() string { return drink(globalFaker.Rand) }
+func Drink() string { return drink(GlobalFaker) }
// Drink will return a random drink name
-func (f *Faker) Drink() string { return drink(f.Rand) }
+func (f *Faker) Drink() string { return drink(f) }
-func drink(r *rand.Rand) string {
- v := getRandValue(r, []string{"food", "drink"})
+func drink(f *Faker) string {
+ v := getRandValue(f, []string{"food", "drink"})
return strings.ToUpper(v[:1]) + v[1:]
}
// Snack will return a random snack name
-func Snack() string { return snack(globalFaker.Rand) }
+func Snack() string { return snack(GlobalFaker) }
// Snack will return a random snack name
-func (f *Faker) Snack() string { return snack(f.Rand) }
+func (f *Faker) Snack() string { return snack(f) }
-func snack(r *rand.Rand) string {
- v := getRandValue(r, []string{"food", "snack"})
+func snack(f *Faker) string {
+ v := getRandValue(f, []string{"food", "snack"})
return strings.ToUpper(v[:1]) + v[1:]
}
// Dessert will return a random dessert name
-func Dessert() string { return dessert(globalFaker.Rand) }
+func Dessert() string { return dessert(GlobalFaker) }
// Dessert will return a random dessert name
-func (f *Faker) Dessert() string { return dessert(f.Rand) }
+func (f *Faker) Dessert() string { return dessert(f) }
-func dessert(r *rand.Rand) string {
- v := getRandValue(r, []string{"food", "dessert"})
+func dessert(f *Faker) string {
+ v := getRandValue(f, []string{"food", "dessert"})
return strings.ToUpper(v[:1]) + v[1:]
}
@@ -94,8 +93,8 @@ func addFoodLookup() {
Description: "Edible plant part, typically sweet, enjoyed as a natural snack or dessert",
Example: "Peach",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return fruit(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return fruit(f), nil
},
})
@@ -105,8 +104,8 @@ func addFoodLookup() {
Description: "Edible plant or part of a plant, often used in savory cooking or salads",
Example: "Amaranth Leaves",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return vegetable(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return vegetable(f), nil
},
})
@@ -116,8 +115,8 @@ func addFoodLookup() {
Description: "First meal of the day, typically eaten in the morning",
Example: "Blueberry banana happy face pancakes",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return breakfast(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return breakfast(f), nil
},
})
@@ -127,8 +126,8 @@ func addFoodLookup() {
Description: "Midday meal, often lighter than dinner, eaten around noon",
Example: "No bake hersheys bar pie",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return lunch(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return lunch(f), nil
},
})
@@ -138,8 +137,8 @@ func addFoodLookup() {
Description: "Evening meal, typically the day's main and most substantial meal",
Example: "Wild addicting dip",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return dinner(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return dinner(f), nil
},
})
@@ -149,8 +148,8 @@ func addFoodLookup() {
Description: "Liquid consumed for hydration, pleasure, or nutritional benefits",
Example: "Soda",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return drink(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return drink(f), nil
},
})
@@ -160,8 +159,8 @@ func addFoodLookup() {
Description: "Random snack",
Example: "Small, quick food item eaten between meals",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return snack(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return snack(f), nil
},
})
@@ -171,8 +170,8 @@ func addFoodLookup() {
Description: "Sweet treat often enjoyed after a meal",
Example: "French napoleons",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return dessert(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return dessert(f), nil
},
})
}
diff --git a/food_test.go b/food_test.go
index 5aa3e3f1..b9027158 100644
--- a/food_test.go
+++ b/food_test.go
@@ -9,302 +9,158 @@ func ExampleFruit() {
Seed(11)
fmt.Println(Fruit())
- // Output: Peach
+ // Output: Redcurrant
}
func ExampleFaker_Fruit() {
f := New(11)
fmt.Println(f.Fruit())
- // Output: Peach
+ // Output: Redcurrant
}
func BenchmarkFruit(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Fruit()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Fruit()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Fruit()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Fruit()
+ }
}
func ExampleVegetable() {
Seed(11)
fmt.Println(Vegetable())
- // Output: Amaranth Leaves
+ // Output: Sweet Potato
}
func ExampleFaker_Vegetable() {
f := New(11)
fmt.Println(f.Vegetable())
- // Output: Amaranth Leaves
+ // Output: Sweet Potato
}
func BenchmarkVegetable(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Vegetable()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Vegetable()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Vegetable()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Vegetable()
+ }
}
func ExampleBreakfast() {
Seed(11)
fmt.Println(Breakfast())
- // Output: Blueberry banana happy face pancakes
+ // Output: Purple cow
}
func ExampleFaker_Breakfast() {
f := New(11)
fmt.Println(f.Breakfast())
- // Output: Blueberry banana happy face pancakes
+ // Output: Purple cow
}
func BenchmarkBreakfast(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Breakfast()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Breakfast()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Breakfast()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Breakfast()
+ }
}
func ExampleLunch() {
Seed(11)
fmt.Println(Lunch())
- // Output: No bake hersheys bar pie
+ // Output: Quick chile relleno casserole
}
func ExampleFaker_Lunch() {
f := New(11)
fmt.Println(f.Lunch())
- // Output: No bake hersheys bar pie
+ // Output: Quick chile relleno casserole
}
func BenchmarkLunch(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Lunch()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Lunch()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Lunch()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Lunch()
+ }
}
func ExampleDinner() {
Seed(11)
fmt.Println(Dinner())
- // Output: Wild addicting dip
+ // Output: German apple cake with cream cheese frosting
}
func ExampleFaker_Dinner() {
f := New(11)
fmt.Println(f.Dinner())
- // Output: Wild addicting dip
+ // Output: German apple cake with cream cheese frosting
}
func BenchmarkDinner(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Dinner()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Dinner()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Dinner()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Dinner()
+ }
}
func ExampleDrink() {
Seed(11)
fmt.Println(Drink())
- // Output: Juice
+ // Output: Wine
}
func ExampleFaker_Drink() {
f := New(11)
fmt.Println(f.Drink())
- // Output: Juice
+ // Output: Wine
}
func BenchmarkDrink(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Drink()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Drink()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Drink()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Drink()
+ }
}
func ExampleSnack() {
Seed(11)
fmt.Println(Snack())
- // Output: Hoisin marinated wing pieces
+ // Output: Fantastic banana bran muffins
}
func ExampleFaker_Snack() {
f := New(11)
fmt.Println(f.Snack())
- // Output: Hoisin marinated wing pieces
+ // Output: Fantastic banana bran muffins
}
func BenchmarkSnack(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Snack()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Snack()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Snack()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Snack()
+ }
}
func ExampleDessert() {
Seed(11)
fmt.Println(Dessert())
- // Output: French napoleons
+ // Output: Amish cream pie
}
func ExampleFaker_Dessert() {
f := New(11)
fmt.Println(f.Dessert())
- // Output: French napoleons
+ // Output: Amish cream pie
}
func BenchmarkDessert(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Dessert()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Dessert()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Dessert()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Dessert()
+ }
}
diff --git a/game.go b/game.go
index 5c1bc369..0e137000 100644
--- a/game.go
+++ b/game.go
@@ -2,33 +2,32 @@ package gofakeit
import (
"fmt"
- "math/rand"
"strings"
)
// Gamertag will generate a random video game username
-func Gamertag() string { return gamertag(globalFaker.Rand) }
+func Gamertag() string { return gamertag(GlobalFaker) }
// Gamertag will generate a random video game username
-func (f *Faker) Gamertag() string { return gamertag(f.Rand) }
+func (f *Faker) Gamertag() string { return gamertag(f) }
-func gamertag(r *rand.Rand) string {
+func gamertag(f *Faker) string {
str := ""
- num := number(r, 1, 4)
+ num := number(f, 1, 4)
switch num {
case 1:
- str = fmt.Sprintf("%s%ser", title(nounConcrete(r)), title(verbAction(r)))
+ str = fmt.Sprintf("%s%ser", title(nounConcrete(f)), title(verbAction(f)))
case 2:
- str = fmt.Sprintf("%s%s", title(adjectiveDescriptive(r)), title(animal(r)))
+ str = fmt.Sprintf("%s%s", title(adjectiveDescriptive(f)), title(animal(f)))
case 3:
- str = fmt.Sprintf("%s%s", title(adjectiveDescriptive(r)), title(nounConcrete(r)))
+ str = fmt.Sprintf("%s%s", title(adjectiveDescriptive(f)), title(nounConcrete(f)))
case 4:
- str = fmt.Sprintf("%s%s", title(fruit(r)), title(adjectiveDescriptive(r)))
+ str = fmt.Sprintf("%s%s", title(fruit(f)), title(adjectiveDescriptive(f)))
}
// Randomly determine if we should add a number
- if r.Intn(3) == 1 {
- str += digitN(r, uint(number(r, 1, 3)))
+ if f.IntN(3) == 1 {
+ str += digitN(f, uint(number(f, 1, 3)))
}
// Remove any spaces
@@ -38,12 +37,12 @@ func gamertag(r *rand.Rand) string {
}
// Dice will generate a random set of dice
-func Dice(numDice uint, sides []uint) []uint { return dice(globalFaker.Rand, numDice, sides) }
+func Dice(numDice uint, sides []uint) []uint { return dice(GlobalFaker, numDice, sides) }
// Dice will generate a random set of dice
-func (f *Faker) Dice(numDice uint, sides []uint) []uint { return dice(f.Rand, numDice, sides) }
+func (f *Faker) Dice(numDice uint, sides []uint) []uint { return dice(f, numDice, sides) }
-func dice(r *rand.Rand, numDice uint, sides []uint) []uint {
+func dice(f *Faker, numDice uint, sides []uint) []uint {
dice := make([]uint, numDice)
// If we dont have any sides well set the sides to 6
@@ -54,9 +53,9 @@ func dice(r *rand.Rand, numDice uint, sides []uint) []uint {
for i := range dice {
// If sides[i] doesnt exist use the first side
if len(sides)-1 < i {
- dice[i] = uint(number(r, 1, int(sides[0])))
+ dice[i] = uint(number(f, 1, int(sides[0])))
} else {
- dice[i] = uint(number(r, 1, int(sides[i])))
+ dice[i] = uint(number(f, 1, int(sides[i])))
}
}
@@ -70,8 +69,8 @@ func addGameLookup() {
Description: "User-selected online username or alias used for identification in games",
Example: "footinterpret63",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return gamertag(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return gamertag(f), nil
},
})
@@ -85,7 +84,7 @@ func addGameLookup() {
{Field: "numdice", Display: "Number of Dice", Type: "uint", Default: "1", Description: "Number of dice to roll"},
{Field: "sides", Display: "Number of Sides", Type: "[]uint", Default: "[6]", Description: "Number of sides on each dice"},
},
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
numDice, err := info.GetUint(m, "numdice")
if err != nil {
return nil, err
@@ -96,7 +95,7 @@ func addGameLookup() {
return nil, err
}
- return dice(r, numDice, sides), nil
+ return dice(f, numDice, sides), nil
},
})
}
diff --git a/game_test.go b/game_test.go
index 6f09c66f..15c8e4a0 100644
--- a/game_test.go
+++ b/game_test.go
@@ -9,14 +9,14 @@ func ExampleGamertag() {
Seed(11)
fmt.Println(Gamertag())
- // Output: PurpleSheep5
+ // Output: TurkeyThinker
}
func ExampleFaker_Gamertag() {
f := New(11)
fmt.Println(f.Gamertag())
- // Output: PurpleSheep5
+ // Output: TurkeyThinker
}
func TestGamertag(t *testing.T) {
@@ -29,27 +29,9 @@ func TestGamertag(t *testing.T) {
}
func BenchmarkGamertag(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Gamertag()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Gamertag()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Gamertag()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Gamertag()
+ }
}
func ExampleDice() {
@@ -118,25 +100,7 @@ func TestDiceOneSide(t *testing.T) {
}
func BenchmarkDice(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Dice(1, []uint{6})
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Dice(1, []uint{6})
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Dice(1, []uint{6})
- }
- })
+ for i := 0; i < b.N; i++ {
+ Dice(1, []uint{6})
+ }
}
diff --git a/generate.go b/generate.go
index 342a3a59..d61366c2 100644
--- a/generate.go
+++ b/generate.go
@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"math"
- "math/rand"
"regexp/syntax"
"strings"
)
@@ -24,7 +23,7 @@ import (
// Ex: ??? - fda - random letters
//
// For a complete list of runnable functions use FuncsLookup
-func Generate(dataVal string) string { return generate(globalFaker.Rand, dataVal) }
+func Generate(dataVal string) string { return generate(GlobalFaker, dataVal) }
// Generate fake information from given string.
// Replaceable values should be within {}
@@ -40,12 +39,12 @@ func Generate(dataVal string) string { return generate(globalFaker.Rand, dataVal
// Ex: ??? - fda - random letters
//
// For a complete list of runnable functions use FuncsLookup
-func (f *Faker) Generate(dataVal string) string { return generate(f.Rand, dataVal) }
+func (f *Faker) Generate(dataVal string) string { return generate(f, dataVal) }
-func generate(r *rand.Rand, dataVal string) string {
+func generate(f *Faker, dataVal string) string {
// Replace # with numbers and ? with letters
- dataVal = replaceWithNumbers(r, dataVal)
- dataVal = replaceWithLetters(r, dataVal)
+ dataVal = replaceWithNumbers(f, dataVal)
+ dataVal = replaceWithLetters(f, dataVal)
// Check if string has any replaceable values
if !strings.Contains(dataVal, "{") && !strings.Contains(dataVal, "}") {
@@ -120,7 +119,7 @@ func generate(r *rand.Rand, dataVal string) string {
}
// Call function
- fValue, err := info.Generate(r, mapParams, info)
+ fValue, err := info.Generate(f, mapParams, info)
if err != nil {
// If we came across an error just dont replace value
dataVal = strings.Replace(dataVal, "{"+fParts+"}", err.Error(), 1)
@@ -160,14 +159,14 @@ type FixedWidthOptions struct {
// FixedWidth generates an table of random data in fixed width format
// A nil FixedWidthOptions returns a randomly structured FixedWidth.
-func FixedWidth(co *FixedWidthOptions) (string, error) { return fixeWidthFunc(globalFaker.Rand, co) }
+func FixedWidth(co *FixedWidthOptions) (string, error) { return fixeWidthFunc(GlobalFaker, co) }
// FixedWidth generates an table of random data in fixed width format
// A nil FixedWidthOptions returns a randomly structured FixedWidth.
-func (f *Faker) FixedWidth(co *FixedWidthOptions) (string, error) { return fixeWidthFunc(f.Rand, co) }
+func (f *Faker) FixedWidth(co *FixedWidthOptions) (string, error) { return fixeWidthFunc(f, co) }
// Function to generate a fixed width document
-func fixeWidthFunc(r *rand.Rand, co *FixedWidthOptions) (string, error) {
+func fixeWidthFunc(f *Faker, co *FixedWidthOptions) (string, error) {
// If we didn't get FixedWidthOptions, create a new random one
if co == nil {
co = &FixedWidthOptions{}
@@ -175,7 +174,7 @@ func fixeWidthFunc(r *rand.Rand, co *FixedWidthOptions) (string, error) {
// Make sure you set a row count
if co.RowCount <= 0 {
- co.RowCount = r.Intn(10) + 1
+ co.RowCount = f.IntN(10) + 1
}
// Check fields
@@ -208,13 +207,13 @@ func fixeWidthFunc(r *rand.Rand, co *FixedWidthOptions) (string, error) {
if funcInfo == nil {
// Try to run the function through generate
for i := 0; i < co.RowCount; i++ {
- row = append(row, generate(r, field.Function))
+ row = append(row, generate(f, field.Function))
}
} else {
// Generate function value
var err error
for i := 0; i < co.RowCount; i++ {
- value, err = funcInfo.Generate(r, &field.Params, funcInfo)
+ value, err = funcInfo.Generate(f, &field.Params, funcInfo)
if err != nil {
value = ""
}
@@ -265,12 +264,12 @@ func fixeWidthFunc(r *rand.Rand, co *FixedWidthOptions) (string, error) {
}
// Regex will generate a string based upon a RE2 syntax
-func Regex(regexStr string) string { return regex(globalFaker.Rand, regexStr) }
+func Regex(regexStr string) string { return regex(GlobalFaker, regexStr) }
// Regex will generate a string based upon a RE2 syntax
-func (f *Faker) Regex(regexStr string) string { return regex(f.Rand, regexStr) }
+func (f *Faker) Regex(regexStr string) string { return regex(f, regexStr) }
-func regex(r *rand.Rand, regexStr string) (gen string) {
+func regex(f *Faker, regexStr string) (gen string) {
re, err := syntax.Parse(regexStr, syntax.Perl)
if err != nil {
return "Could not parse regex string"
@@ -279,16 +278,16 @@ func regex(r *rand.Rand, regexStr string) (gen string) {
// Panic catch
defer func() {
if r := recover(); r != nil {
- gen = fmt.Sprint(r)
+ gen = fmt.Sprint(f)
return
}
}()
- return regexGenerate(r, re, len(regexStr)*100)
+ return regexGenerate(f, re, len(regexStr)*100)
}
-func regexGenerate(ra *rand.Rand, re *syntax.Regexp, limit int) string {
+func regexGenerate(f *Faker, re *syntax.Regexp, limit int) string {
if limit <= 0 {
panic("Length limit reached when generating output")
}
@@ -331,11 +330,11 @@ func regexGenerate(ra *rand.Rand, re *syntax.Regexp, limit int) string {
}
}
if len(chars) > 0 {
- return string([]byte{chars[ra.Intn(len(chars))]})
+ return string([]byte{chars[f.IntN(len(chars))]})
}
}
- r := ra.Intn(int(sum))
+ r := f.IntN(int(sum))
var ru rune
sum = 0
for i := 0; i < len(re.Rune); i += 2 {
@@ -349,7 +348,7 @@ func regexGenerate(ra *rand.Rand, re *syntax.Regexp, limit int) string {
return string(ru)
case syntax.OpAnyCharNotNL, syntax.OpAnyChar: // matches any character(and except newline)
- return randCharacter(ra, allStr)
+ return randCharacter(f, allStr)
case syntax.OpBeginLine: // matches empty string at beginning of line
case syntax.OpEndLine: // matches empty string at end of line
case syntax.OpBeginText: // matches empty string at beginning of text
@@ -357,28 +356,28 @@ func regexGenerate(ra *rand.Rand, re *syntax.Regexp, limit int) string {
case syntax.OpWordBoundary: // matches word boundary `\b`
case syntax.OpNoWordBoundary: // matches word non-boundary `\B`
case syntax.OpCapture: // capturing subexpression with index Cap, optional name Name
- return regexGenerate(ra, re.Sub0[0], limit)
+ return regexGenerate(f, re.Sub0[0], limit)
case syntax.OpStar: // matches Sub[0] zero or more times
var b strings.Builder
- for i := 0; i < number(ra, 0, 10); i++ {
+ for i := 0; i < number(f, 0, 10); i++ {
for _, rs := range re.Sub {
- b.WriteString(regexGenerate(ra, rs, limit-b.Len()))
+ b.WriteString(regexGenerate(f, rs, limit-b.Len()))
}
}
return b.String()
case syntax.OpPlus: // matches Sub[0] one or more times
var b strings.Builder
- for i := 0; i < number(ra, 1, 10); i++ {
+ for i := 0; i < number(f, 1, 10); i++ {
for _, rs := range re.Sub {
- b.WriteString(regexGenerate(ra, rs, limit-b.Len()))
+ b.WriteString(regexGenerate(f, rs, limit-b.Len()))
}
}
return b.String()
case syntax.OpQuest: // matches Sub[0] zero or one times
var b strings.Builder
- for i := 0; i < number(ra, 0, 1); i++ {
+ for i := 0; i < number(f, 0, 1); i++ {
for _, rs := range re.Sub {
- b.WriteString(regexGenerate(ra, rs, limit-b.Len()))
+ b.WriteString(regexGenerate(f, rs, limit-b.Len()))
}
}
return b.String()
@@ -387,84 +386,84 @@ func regexGenerate(ra *rand.Rand, re *syntax.Regexp, limit int) string {
count := 0
re.Max = int(math.Min(float64(re.Max), float64(10)))
if re.Max > re.Min {
- count = ra.Intn(re.Max - re.Min + 1)
+ count = f.IntN(re.Max - re.Min + 1)
}
for i := 0; i < re.Min || i < (re.Min+count); i++ {
for _, rs := range re.Sub {
- b.WriteString(regexGenerate(ra, rs, limit-b.Len()))
+ b.WriteString(regexGenerate(f, rs, limit-b.Len()))
}
}
return b.String()
case syntax.OpConcat: // matches concatenation of Subs
var b strings.Builder
for _, rs := range re.Sub {
- b.WriteString(regexGenerate(ra, rs, limit-b.Len()))
+ b.WriteString(regexGenerate(f, rs, limit-b.Len()))
}
return b.String()
case syntax.OpAlternate: // matches alternation of Subs
- return regexGenerate(ra, re.Sub[number(ra, 0, len(re.Sub)-1)], limit)
+ return regexGenerate(f, re.Sub[number(f, 0, len(re.Sub)-1)], limit)
}
return ""
}
// Map will generate a random set of map data
-func Map() map[string]any { return mapFunc(globalFaker.Rand) }
+func Map() map[string]any { return mapFunc(GlobalFaker) }
// Map will generate a random set of map data
-func (f *Faker) Map() map[string]any { return mapFunc(f.Rand) }
+func (f *Faker) Map() map[string]any { return mapFunc(f) }
-func mapFunc(r *rand.Rand) map[string]any {
+func mapFunc(f *Faker) map[string]any {
m := map[string]any{}
randWordType := func() string {
- s := randomString(r, []string{"lorem", "bs", "job", "name", "address"})
+ s := randomString(f, []string{"lorem", "bs", "job", "name", "address"})
switch s {
case "bs":
- return bs(r)
+ return bs(f)
case "job":
- return jobTitle(r)
+ return jobTitle(f)
case "name":
- return name(r)
+ return name(f)
case "address":
- return street(r) + ", " + city(r) + ", " + state(r) + " " + zip(r)
+ return street(f) + ", " + city(f) + ", " + state(f) + " " + zip(f)
}
- return word(r)
+ return word(f)
}
randSlice := func() []string {
var sl []string
- for ii := 0; ii < number(r, 3, 10); ii++ {
- sl = append(sl, word(r))
+ for ii := 0; ii < number(f, 3, 10); ii++ {
+ sl = append(sl, word(f))
}
return sl
}
- for i := 0; i < number(r, 3, 10); i++ {
- t := randomString(r, []string{"string", "int", "float", "slice", "map"})
+ for i := 0; i < number(f, 3, 10); i++ {
+ t := randomString(f, []string{"string", "int", "float", "slice", "map"})
switch t {
case "string":
- m[word(r)] = randWordType()
+ m[word(f)] = randWordType()
case "int":
- m[word(r)] = number(r, 1, 10000000)
+ m[word(f)] = number(f, 1, 10000000)
case "float":
- m[word(r)] = float32Range(r, 1, 1000000)
+ m[word(f)] = float32Range(f, 1, 1000000)
case "slice":
- m[word(r)] = randSlice()
+ m[word(f)] = randSlice()
case "map":
mm := map[string]any{}
- tt := randomString(r, []string{"string", "int", "float", "slice"})
+ tt := randomString(f, []string{"string", "int", "float", "slice"})
switch tt {
case "string":
- mm[word(r)] = randWordType()
+ mm[word(f)] = randWordType()
case "int":
- mm[word(r)] = number(r, 1, 10000000)
+ mm[word(f)] = number(f, 1, 10000000)
case "float":
- mm[word(r)] = float32Range(r, 1, 1000000)
+ mm[word(f)] = float32Range(f, 1, 1000000)
case "slice":
- mm[word(r)] = randSlice()
+ mm[word(f)] = randSlice()
}
- m[word(r)] = mm
+ m[word(f)] = mm
}
}
@@ -481,7 +480,7 @@ func addGenerateLookup() {
Params: []Param{
{Field: "str", Display: "String", Type: "string", Description: "String value to generate from"},
},
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
str, err := info.GetString(m, "str")
if err != nil {
return nil, err
@@ -492,7 +491,7 @@ func addGenerateLookup() {
return nil, errors.New("string length is too large. limit to 1000 characters")
}
- return generate(r, str), nil
+ return generate(f, str), nil
},
})
@@ -510,7 +509,7 @@ Lura Lockman zacherykuhic@feil.name S8gV7Z64KlHG 12`,
{Field: "rowcount", Display: "Row Count", Type: "int", Default: "10", Description: "Number of rows"},
{Field: "fields", Display: "Fields", Type: "[]Field", Description: "Fields name, function and params"},
},
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
co := FixedWidthOptions{}
rowCount, err := info.GetInt(m, "rowcount")
@@ -536,7 +535,7 @@ Lura Lockman zacherykuhic@feil.name S8gV7Z64KlHG 12`,
return nil, errors.New("missing fields")
}
- out, err := fixeWidthFunc(r, &co)
+ out, err := fixeWidthFunc(f, &co)
if err != nil {
return nil, err
}
@@ -554,7 +553,7 @@ Lura Lockman zacherykuhic@feil.name S8gV7Z64KlHG 12`,
Params: []Param{
{Field: "str", Display: "String", Type: "string", Description: "Regex RE2 syntax string"},
},
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
str, err := info.GetString(m, "str")
if err != nil {
return nil, err
@@ -565,7 +564,7 @@ Lura Lockman zacherykuhic@feil.name S8gV7Z64KlHG 12`,
return nil, errors.New("string length is too large. limit to 500 characters")
}
- return regex(r, str), nil
+ return regex(f, str), nil
},
})
@@ -582,8 +581,8 @@ Lura Lockman zacherykuhic@feil.name S8gV7Z64KlHG 12`,
}`,
Output: "map[string]any",
ContentType: "application/json",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return mapFunc(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return mapFunc(f), nil
},
})
}
diff --git a/generate_fuzz_test.go b/generate_fuzz_test.go
deleted file mode 100644
index 4deeb6db..00000000
--- a/generate_fuzz_test.go
+++ /dev/null
@@ -1,112 +0,0 @@
-//go:build go1.18
-// +build go1.18
-
-package gofakeit
-
-import (
- "encoding/binary"
- "math/rand"
- "regexp"
- "strings"
- "testing"
-)
-
-func FuzzRegex(f *testing.F) {
- for i, regex := range regexes {
- buffer := make([]byte, 8)
- binary.BigEndian.PutUint64(buffer, uint64(i*i*1234567))
- // Reuse TestRegex cases to seed corpus.
- f.Add(buffer, regex.test)
-
- // Cases found and skipped by fuzz test.
- f.Add([]byte("0"), string("$0")) // can not match any string
- f.Add([]byte("0"), string("0^00")) // can not match any string
- f.Add([]byte("0"), string("000\\A")) // `\A` gives unexpected results
- f.Add([]byte("0"), string("\\b")) // `\b` gives unexpected results
-
- // Fixed by modifying regexGenerate.
- f.Add([]byte("("), string("((5555555555555555){700})")) // OOM after fuzz run for a while. fixed by adding limit to regexGenerate
-
- // Fixed in notSoRandom.
- f.Add([]byte("\xff\xff\xff\xff\xff\xff\xff\xf1"), string("123[0-2]w{3}")) // choose 1 in 3 loops forever if notSoRandom loops it self instead of using a random tail
- }
- f.Fuzz(func(t *testing.T, rand []byte, regex string) {
- if len(regex) > 20 {
- return // long regexes take longer to test without adding much, increase this limit will make it easer to find OOM and timeouts.
- }
-
- // case added after each character gives bad result to get other cases
- if strings.ContainsAny(regex, `^$\`) {
- return
- }
-
- regex = "^" + regex + "$" // make sure we do a full capture
-
- // Try to compile regexTest
- regCompile, err := regexp.Compile(regex)
- if err != nil {
- return // Ignore bad regex
- }
-
- // Let fuzz have control over random behavior
- fuzzRand := ¬SoRandom{}
- fuzzRand.useBytes(rand)
- faker := NewCustom(fuzzRand)
-
- // Generate string and test if it matches the regex syntax
- reg := faker.Regex(regex)
- if reg == "Length limit reached when generating output" {
- // ignore LimitReached error
- return
- }
- if !regCompile.MatchString(reg) {
- t.Error("Generated data does not match regex. Regex: ", regex, " output: ", reg)
- }
- })
-}
-
-// notSoRandom is a random source that start with a stream of predetermined data.
-// This allows fuzz to slowly change sudo random behavior.
-type notSoRandom struct {
- data []uint64
- offset int
-
- // Make long tail behavior more random once we run out of data.
- // This avoids dead loop in code that expects a statically random source.
- tail rand.Source64
-}
-
-func (r *notSoRandom) Int63() int64 {
- if r.tail != nil {
- return r.tail.Int63()
- }
- return int64(r.Uint64() & ^uint64(1<<63))
-}
-
-func (r *notSoRandom) Uint64() uint64 {
- if r.tail != nil {
- return r.tail.Uint64()
- }
- out := r.data[r.offset]
- r.offset = (r.offset + 1) % len(r.data)
- if r.offset == 0 {
- r.tail = rand.NewSource(int64(out)).(rand.Source64)
- }
- return out
-}
-
-func (r *notSoRandom) Seed(seed int64) {
- panic("unimplemented")
-}
-
-func (r *notSoRandom) useBytes(seed []byte) {
- if len(seed) == 0 || len(seed)%8 != 0 {
- r.useBytes(append(seed, 0))
- return
- }
- var data []uint64
- for i := 0; i+7 < len(seed); i += 8 {
- data = append(data, binary.BigEndian.Uint64(seed[i:]))
- }
- r.data = data
-}
diff --git a/generate_test.go b/generate_test.go
index af3a95eb..ec1a1cab 100644
--- a/generate_test.go
+++ b/generate_test.go
@@ -24,8 +24,8 @@ func TestGenerate_Sub(t *testing.T) {
Seed(11)
output := Generate("{randomstring:[{firstname},{lastname}]}")
- if output != "Moen" {
- t.Error("Did not generate what was expected. Got: ", output)
+ if output == "" {
+ t.Error("Output was empty")
}
})
@@ -33,8 +33,8 @@ func TestGenerate_Sub(t *testing.T) {
Seed(11)
output := Generate("{randomstring:[{randomstring:[{firstname},{lastname}]},{randomstring:[{firstname},{lastname}]}]}")
- if output != "Kozey" {
- t.Error("Did not generate what was expected. Got: ", output)
+ if output == "" {
+ t.Error("Output was empty")
}
})
}
@@ -50,13 +50,13 @@ func ExampleGenerate() {
fmt.Println(Generate("{number:1,50}"))
fmt.Println(Generate("{shufflestrings:[key:value,int:string,1:2,a:b]}"))
- // Output: Markus Moen ssn is 526643139 and lives at 599 Daleton
- // Congolese choir computer.
- // [3 1 2]
+ // Output: Sonny Stiedemann ssn is 279582238 and lives at 2759 Stationside
+ // How shall cut.
+ // [1 2 3]
// 2
- // 4
- // 17
- // [int:string 1:2 a:b key:value]
+ // 3
+ // 47
+ // [1:2 int:string a:b key:value]
}
func ExampleFaker_Generate() {
@@ -70,13 +70,13 @@ func ExampleFaker_Generate() {
fmt.Println(f.Generate("{number:1,50}"))
fmt.Println(f.Generate("{shufflestrings:[key:value,int:string,1:2,a:b]}"))
- // Output: Markus Moen ssn is 526643139 and lives at 599 Daleton
- // Congolese choir computer.
- // [3 1 2]
+ // Output: Sonny Stiedemann ssn is 279582238 and lives at 2759 Stationside
+ // How shall cut.
+ // [1 2 3]
// 2
- // 4
- // 17
- // [int:string 1:2 a:b key:value]
+ // 3
+ // 47
+ // [1:2 int:string a:b key:value]
}
func BenchmarkGenerate(b *testing.B) {
@@ -91,22 +91,6 @@ func BenchmarkGenerate(b *testing.B) {
Generate("{randomstring:[{randomstring:[{firstname},{lastname}]},{randomstring:[{firstname},{lastname}]}]}")
}
})
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Generate("{firstname} {lastname} {email} #?#?#?")
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Generate("{firstname} {lastname} {email} #?#?#?")
- }
- })
}
func ExampleFixedWidth() {
@@ -127,11 +111,10 @@ func ExampleFixedWidth() {
fmt.Println(string(value))
- // Output:
- // Name Email Password Age
- // Markus Moen sylvanmraz@murphy.net 46HX9elvE5zl 43
- // Alayna Wuckert santinostanton@carroll.biz l6A0EVSC90w2 11
- // Lura Lockman zacherykuhic@feil.name xxL47424u8Ts 4
+ // Output: Name Email Password Age
+ // Sonny Stiedemann mollielegros@wilderman.org 3T8l34B5F0eb 62
+ // Cody Donnelly stevebins@robel.io 3fnu2C12baqe 9
+ // Julius Farrell tomasaullrich@hane.name e8W8SJGZi1Y4 77
}
func ExampleFixedWidth_default() {
@@ -144,9 +127,16 @@ func ExampleFixedWidth_default() {
fmt.Println(string(value))
- // Output:
- // Name Email Password
- // Marcel Pagac anibalkozey@lockman.name ETZmouyV0q1W
+ // Output: Name Email Password
+ // Russ Donnelly missourigrimes@rohan.io N3xh07881HKv
+ // Cole Leannon evanadams@marquardt.com n2fja08VHMgw
+ // Darien Rempel thorajerde@cormier.com ZhMPq5v8z6iP
+ // Kaitlyn Wilderman constancenienow@smitham.io MkoTT5v5Mv6Q
+ // Rahul Turner irvingbins@lemke.io 8Wy0UV016u88
+ // April Robel beaulahmayert@kautzer.net ykgR5bO83YSa
+ // Tomasa Waters lelandwaelchi@beahan.net k68Ew58F9a0V
+ // Sunny Hane dawnbaumbach@mcdermott.biz AbUjm6x5dwd8
+ // Hilma Jast lavernerobel@bailey.io MyY49BLUWKCh
}
func ExampleFixedWidth_noHeader() {
@@ -167,10 +157,9 @@ func ExampleFixedWidth_noHeader() {
fmt.Println(value)
- // Output:
- // Markus Moen sylvanmraz@murphy.net 46HX9elvE5zl 43
- // Alayna Wuckert santinostanton@carroll.biz l6A0EVSC90w2 11
- // Lura Lockman zacherykuhic@feil.name xxL47424u8Ts 4
+ // Output: Sonny Stiedemann mollielegros@wilderman.org 3T8l34B5F0eb 62
+ // Cody Donnelly stevebins@robel.io 3fnu2C12baqe 9
+ // Julius Farrell tomasaullrich@hane.name e8W8SJGZi1Y4 77
}
func ExampleFaker_FixedWidth() {
@@ -191,11 +180,10 @@ func ExampleFaker_FixedWidth() {
fmt.Println(string(value))
- // Output:
- // Name Email Password Age
- // Markus Moen sylvanmraz@murphy.net 46HX9elvE5zl 43
- // Alayna Wuckert santinostanton@carroll.biz l6A0EVSC90w2 11
- // Lura Lockman zacherykuhic@feil.name xxL47424u8Ts 4
+ // Output: Name Email Password Age
+ // Sonny Stiedemann mollielegros@wilderman.org 3T8l34B5F0eb 62
+ // Cody Donnelly stevebins@robel.io 3fnu2C12baqe 9
+ // Julius Farrell tomasaullrich@hane.name e8W8SJGZi1Y4 77
}
func TestFixedWidthLookup(t *testing.T) {
@@ -213,7 +201,7 @@ func TestFixedWidthLookup(t *testing.T) {
},
}
- output, err := info.Generate(faker.Rand, &m, info)
+ output, err := info.Generate(faker, &m, info)
if err != nil {
t.Fatal(err.Error())
}
@@ -246,56 +234,16 @@ func BenchmarkFixedWidthLookup100(b *testing.B) {
m := MapParams{
"rowcount": {"100"},
"fields": {
- `{"name":"Name","function":"{firstname} {lastname}"}"}`,
- `{"name":"Email","function":"email"}`,
- `{"name":"Password","function":"password","params":{"special":["false"],"length":["20"]}}`,
- `{"name":"Age","function":"{number:1,100}"}`,
- },
- }
- _, err := info.Generate(faker.Rand, &m, info)
- if err != nil {
- b.Fatal(err.Error())
- }
- }
-}
-
-func BenchmarkFixedWidthLookup1000(b *testing.B) {
- faker := New(0)
-
- for i := 0; i < b.N; i++ {
- info := GetFuncLookup("fixed_width")
- m := MapParams{
- "rowcount": {"1000"},
- "fields": {
- `{"name":"Name","function":"{firstname} {lastname}"}"}`,
+ // `{"name":"Name","function":"{firstname} {lastname}"}`,
`{"name":"Email","function":"email"}`,
`{"name":"Password","function":"password","params":{"special":["false"],"length":["20"]}}`,
`{"name":"Age","function":"{number:1,100}"}`,
},
}
- _, err := info.Generate(faker.Rand, &m, info)
+ _, err := info.Generate(faker, &m, info)
if err != nil {
- b.Fatal(err.Error())
- }
- }
-}
-
-func BenchmarkFixedWidthLookup10000(b *testing.B) {
- faker := New(0)
+ // Stack trace
- for i := 0; i < b.N; i++ {
- info := GetFuncLookup("fixed_width")
- m := MapParams{
- "rowcount": {"10000"},
- "fields": {
- `{"name":"Name","function":"{firstname} {lastname}"}"}`,
- `{"name":"Email","function":"email"}`,
- `{"name":"Password","function":"password","params":{"special":["false"],"length":["20"]}}`,
- `{"name":"Age","function":"{number:1,100}"}`,
- },
- }
- _, err := info.Generate(faker.Rand, &m, info)
- if err != nil {
b.Fatal(err.Error())
}
}
@@ -309,10 +257,10 @@ func ExampleRegex() {
fmt.Println(Regex("(hello|world|whats|up)"))
fmt.Println(Regex(`^[a-z]{5,10}@[a-z]{5,10}\.(com|net|org)$`))
- // Output: affec
- // RXHKI
- // world
- // tapwyjdnsm@gtlxw.net
+ // Output: ffbbd
+ // GSNYV
+ // up
+ // tyyxi@kshtyia.net
}
func ExampleFaker_Regex() {
@@ -323,10 +271,10 @@ func ExampleFaker_Regex() {
fmt.Println(f.Regex("(hello|world|whats|up)"))
fmt.Println(f.Regex(`^[a-z]{5,10}@[a-z]{5,10}\.(com|net|org)$`))
- // Output: affec
- // RXHKI
- // world
- // tapwyjdnsm@gtlxw.net
+ // Output: ffbbd
+ // GSNYV
+ // up
+ // tyyxi@kshtyia.net
}
var regexes = []struct{ test string }{
@@ -387,107 +335,72 @@ func TestRegex_Struct(t *testing.T) {
rg := Reggy{}
Struct(&rg)
- if rg.Str1 != "16" {
- t.Errorf("Str1 should be 16 got: %s", rg.Str1)
+ // Test Str1 matches regex
+ if !regexp.MustCompile(`^\d+$`).MatchString(rg.Str1) {
+ t.Errorf("Str1 should match regex: ^\\d+$ got: %s", rg.Str1)
}
- if rg.Str2 != "fP}" {
- t.Errorf("Str2 should be fP} got: %s", rg.Str2)
+ if !regexp.MustCompile(`\D{3}`).MatchString(rg.Str2) {
+ t.Errorf("Str2 should match regex: \\D{3} got: %s", rg.Str2)
}
- if rg.Str3 != "ZZ" {
- t.Errorf("Str3 should be ZZ got: %s", rg.Str3)
+ if !regexp.MustCompile(`Z{2,5}`).MatchString(rg.Str3) {
+ t.Errorf("Str3 should match regex: Z{2,5} got: %s", rg.Str3)
}
- if rg.Str4 != "% z" {
- t.Errorf("Str4 should be %s got: %s", "% z", rg.Str4)
+ if !regexp.MustCompile(`[^1]{3,5}`).MatchString(rg.Str4) {
+ t.Errorf("Str4 should match regex: [^1]{3,5} got: %s", rg.Str4)
}
- if rg.Str5 != "abdef" {
- t.Errorf("Str5 should be abdef got: %s", rg.Str5)
+ if !regexp.MustCompile(`(ab|bc)def`).MatchString(rg.Str5) {
+ t.Errorf("Str5 should match regex: (ab|bc)def got: %s", rg.Str5)
}
- if rg.Str6 != "123a123a123a" {
- t.Errorf("Str6 should be 123a123a123a got: %s", rg.Str6)
+ if !regexp.MustCompile(`((123)?){3}`).MatchString(rg.Str6) {
+ t.Errorf("Str6 should match regex: ((123)?){3} got: %s", rg.Str6)
}
- if rg.Str7 != ">=;-l" {
- t.Errorf("Str7 should be >=;-l got: %s", rg.Str7)
+ if !regexp.MustCompile(`[^abcdef]{5}`).MatchString(rg.Str7) {
+ t.Errorf("Str7 should match regex: [^abcdef]{5} got: %s", rg.Str7)
}
- if rg.Str8 != "nSMKgtlxwn" {
- t.Errorf("Str8 should be nSMKgtlxwn got: %s", rg.Str8)
+ if !regexp.MustCompile(`[a-zA-Z]{10}`).MatchString(rg.Str8) {
+ t.Errorf("Str8 should match regex: [a-zA-Z]{10} got: %s", rg.Str8)
}
- if rg.Str9 != "QHQCL" {
- t.Errorf("Str9 should be QHQCL got: %s", rg.Str9)
+ if !regexp.MustCompile(`[[:upper:]]{5}`).MatchString(rg.Str9) {
+ t.Errorf("Str9 should match regex: [[:upper:]]{5} got: %s", rg.Str9)
}
- if rg.Str10 != "(T}6X" {
- t.Errorf("Str10 should be (T}6X got: %s", rg.Str10)
+ if !regexp.MustCompile(`[^0-5a-z\s]{5}`).MatchString(rg.Str10) {
+ t.Errorf("Str10 should match regex: [^0-5a-z\\s]{5} got: %s", rg.Str10)
}
- if rg.Str11 != "123120aeD" {
- t.Errorf("Str11 should be 123120aeD got: %s", rg.Str11)
+ if !regexp.MustCompile(`123[0-2]+.*\w{3}`).MatchString(rg.Str11) {
+ t.Errorf("Str11 should match regex: 123[0-2]+.*\\w{3} got: %s", rg.Str11)
}
- if rg.Str12 != "hello" {
- t.Errorf("Str12 should be hello got: %s", rg.Str12)
+ if !regexp.MustCompile(`(hello|world|whats|up)`).MatchString(rg.Str12) {
+ t.Errorf("Str12 should match regex: (hello|world|whats|up) got: %s", rg.Str12)
}
- if rg.Str13 != "8/10/2022" {
- t.Errorf("Str13 should be 8/10/2022 got: %s", rg.Str13)
+ if !regexp.MustCompile(`^\d{1,2}[/](1[0-2]|[1-9])[/]((19|20)\d{2})$`).MatchString(rg.Str13) {
+ t.Errorf("Str13 should match regex: ^\\d{1,2}[/](1[0-2]|[1-9])[/]((19|20)\\d{2})$ got: %s", rg.Str13)
}
}
func BenchmarkRegex(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Regex(`(hello|world|whats|up`)
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Regex(`(hello|world|whats|up`)
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Regex(`(hello|world|whats|up`)
- }
- })
+ for i := 0; i < b.N; i++ {
+ Regex(`(hello|world|whats|up`)
+ }
}
func BenchmarkRegexEmail(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Regex("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Regex("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Regex("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
- }
- })
+ for i := 0; i < b.N; i++ {
+ Regex("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
+ }
}
func ExampleMap() {
Seed(11)
fmt.Println(Map())
- // Output: map[here:Manager herself:map[trip:[far computer was unless whom riches]] how:8504801 ouch:Keith Ullrich outstanding:1860846 that:web services]
+ // Output: map[a:map[that:could] above:[sometimes vast whom us scarcely these huh] am:map[how:9310653] depend:map[hey:5402877] out:381794.78 since:916659.94 these:map[frequently:2314010]]
}
func ExampleFaker_Map() {
f := New(11)
fmt.Println(f.Map())
- // Output: map[here:Manager herself:map[trip:[far computer was unless whom riches]] how:8504801 ouch:Keith Ullrich outstanding:1860846 that:web services]
+ // Output: map[a:map[that:could] above:[sometimes vast whom us scarcely these huh] am:map[how:9310653] depend:map[hey:5402877] out:381794.78 since:916659.94 these:map[frequently:2314010]]
}
func TestMap(t *testing.T) {
@@ -497,25 +410,7 @@ func TestMap(t *testing.T) {
}
func BenchmarkMap(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- Map()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.Map()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.Map()
- }
- })
+ for i := 0; i < b.N; i++ {
+ Map()
+ }
}
diff --git a/go.mod b/go.mod
index 49d8fa95..8242e1df 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,3 @@
-module github.com/brianvoe/gofakeit/v6
+module github.com/brianvoe/gofakeit/v7
-go 1.21
+go 1.22
diff --git a/hacker.go b/hacker.go
index 393c558e..dd1bdc26 100644
--- a/hacker.go
+++ b/hacker.go
@@ -1,70 +1,69 @@
package gofakeit
import (
- "math/rand"
"strings"
)
// HackerPhrase will return a random hacker sentence
-func HackerPhrase() string { return hackerPhrase(globalFaker.Rand) }
+func HackerPhrase() string { return hackerPhrase(GlobalFaker) }
// HackerPhrase will return a random hacker sentence
-func (f *Faker) HackerPhrase() string { return hackerPhrase(f.Rand) }
+func (f *Faker) HackerPhrase() string { return hackerPhrase(f) }
-func hackerPhrase(r *rand.Rand) string {
- words := strings.Split(generate(r, getRandValue(r, []string{"hacker", "phrase"})), " ")
+func hackerPhrase(f *Faker) string {
+ words := strings.Split(generate(f, getRandValue(f, []string{"hacker", "phrase"})), " ")
words[0] = strings.ToUpper(words[0][0:1]) + words[0][1:]
return strings.Join(words, " ")
}
// HackerAbbreviation will return a random hacker abbreviation
-func HackerAbbreviation() string { return hackerAbbreviation(globalFaker.Rand) }
+func HackerAbbreviation() string { return hackerAbbreviation(GlobalFaker) }
// HackerAbbreviation will return a random hacker abbreviation
-func (f *Faker) HackerAbbreviation() string { return hackerAbbreviation(f.Rand) }
+func (f *Faker) HackerAbbreviation() string { return hackerAbbreviation(f) }
-func hackerAbbreviation(r *rand.Rand) string {
- return getRandValue(r, []string{"hacker", "abbreviation"})
+func hackerAbbreviation(f *Faker) string {
+ return getRandValue(f, []string{"hacker", "abbreviation"})
}
// HackerAdjective will return a random hacker adjective
-func HackerAdjective() string { return hackerAdjective(globalFaker.Rand) }
+func HackerAdjective() string { return hackerAdjective(GlobalFaker) }
// HackerAdjective will return a random hacker adjective
-func (f *Faker) HackerAdjective() string { return hackerAdjective(f.Rand) }
+func (f *Faker) HackerAdjective() string { return hackerAdjective(f) }
-func hackerAdjective(r *rand.Rand) string {
- return getRandValue(r, []string{"hacker", "adjective"})
+func hackerAdjective(f *Faker) string {
+ return getRandValue(f, []string{"hacker", "adjective"})
}
// HackerNoun will return a random hacker noun
-func HackerNoun() string { return hackerNoun(globalFaker.Rand) }
+func HackerNoun() string { return hackerNoun(GlobalFaker) }
// HackerNoun will return a random hacker noun
-func (f *Faker) HackerNoun() string { return hackerNoun(f.Rand) }
+func (f *Faker) HackerNoun() string { return hackerNoun(f) }
-func hackerNoun(r *rand.Rand) string {
- return getRandValue(r, []string{"hacker", "noun"})
+func hackerNoun(f *Faker) string {
+ return getRandValue(f, []string{"hacker", "noun"})
}
// HackerVerb will return a random hacker verb
-func HackerVerb() string { return hackerVerb(globalFaker.Rand) }
+func HackerVerb() string { return hackerVerb(GlobalFaker) }
// HackerVerb will return a random hacker verb
-func (f *Faker) HackerVerb() string { return hackerVerb(f.Rand) }
+func (f *Faker) HackerVerb() string { return hackerVerb(f) }
-func hackerVerb(r *rand.Rand) string {
- return getRandValue(r, []string{"hacker", "verb"})
+func hackerVerb(f *Faker) string {
+ return getRandValue(f, []string{"hacker", "verb"})
}
// HackeringVerb will return a random hacker ingverb
-func HackeringVerb() string { return hackeringVerb(globalFaker.Rand) }
+func HackeringVerb() string { return hackeringVerb(GlobalFaker) }
// HackeringVerb will return a random hacker ingverb
-func (f *Faker) HackeringVerb() string { return hackeringVerb(f.Rand) }
+func (f *Faker) HackeringVerb() string { return hackeringVerb(f) }
-func hackeringVerb(r *rand.Rand) string {
- return getRandValue(r, []string{"hacker", "ingverb"})
+func hackeringVerb(f *Faker) string {
+ return getRandValue(f, []string{"hacker", "ingverb"})
}
func addHackerLookup() {
@@ -74,8 +73,8 @@ func addHackerLookup() {
Description: "Informal jargon and slang used in the hacking and cybersecurity community",
Example: "If we calculate the program, we can get to the AI pixel through the redundant XSS matrix!",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return hackerPhrase(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return hackerPhrase(f), nil
},
})
@@ -85,8 +84,8 @@ func addHackerLookup() {
Description: "Abbreviations and acronyms commonly used in the hacking and cybersecurity community",
Example: "ADP",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return hackerAbbreviation(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return hackerAbbreviation(f), nil
},
})
@@ -96,8 +95,8 @@ func addHackerLookup() {
Description: "Adjectives describing terms often associated with hackers and cybersecurity experts",
Example: "wireless",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return hackerAdjective(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return hackerAdjective(f), nil
},
})
@@ -107,8 +106,8 @@ func addHackerLookup() {
Description: "Noun representing an element, tool, or concept within the realm of hacking and cybersecurity",
Example: "driver",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return hackerNoun(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return hackerNoun(f), nil
},
})
@@ -118,8 +117,8 @@ func addHackerLookup() {
Description: "Verbs associated with actions and activities in the field of hacking and cybersecurity",
Example: "synthesize",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return hackerVerb(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return hackerVerb(f), nil
},
})
@@ -129,8 +128,8 @@ func addHackerLookup() {
Description: "Verb describing actions and activities related to hacking, often involving computer systems and security",
Example: "connecting",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return hackeringVerb(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return hackeringVerb(f), nil
},
})
}
diff --git a/hacker_test.go b/hacker_test.go
index 683228d6..30247ad4 100644
--- a/hacker_test.go
+++ b/hacker_test.go
@@ -9,226 +9,118 @@ func ExampleHackerPhrase() {
Seed(11)
fmt.Println(HackerPhrase())
- // Output: If we calculate the program, we can get to the AI pixel through the redundant XSS matrix!
+ // Output: Use the optical CSS microchip, then you can write the open-source monitor!
}
func ExampleFaker_HackerPhrase() {
f := New(11)
fmt.Println(f.HackerPhrase())
- // Output: If we calculate the program, we can get to the AI pixel through the redundant XSS matrix!
+ // Output: Use the optical CSS microchip, then you can write the open-source monitor!
}
func BenchmarkHackerPhrase(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- HackerPhrase()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.HackerPhrase()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.HackerPhrase()
- }
- })
+ for i := 0; i < b.N; i++ {
+ HackerPhrase()
+ }
}
func ExampleHackerAbbreviation() {
Seed(11)
fmt.Println(HackerAbbreviation())
- // Output: ADP
+ // Output: SCSI
}
func ExampleFaker_HackerAbbreviation() {
f := New(11)
fmt.Println(f.HackerAbbreviation())
- // Output: ADP
+ // Output: SCSI
}
func BenchmarkHackerAbbreviation(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- HackerAbbreviation()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.HackerAbbreviation()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.HackerAbbreviation()
- }
- })
+ for i := 0; i < b.N; i++ {
+ HackerAbbreviation()
+ }
}
func ExampleHackerAdjective() {
Seed(11)
fmt.Println(HackerAdjective())
- // Output: wireless
+ // Output: solid state
}
func ExampleFaker_HackerAdjective() {
f := New(11)
fmt.Println(f.HackerAdjective())
- // Output: wireless
+ // Output: solid state
}
func BenchmarkHackerAdjective(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- HackerAdjective()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.HackerAdjective()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.HackerAdjective()
- }
- })
+ for i := 0; i < b.N; i++ {
+ HackerAdjective()
+ }
}
func ExampleHackerNoun() {
Seed(11)
fmt.Println(HackerNoun())
- // Output: driver
+ // Output: circuit
}
func ExampleFaker_HackerNoun() {
f := New(11)
fmt.Println(f.HackerNoun())
- // Output: driver
+ // Output: circuit
}
func BenchmarkHackerNoun(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- HackerNoun()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.HackerNoun()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.HackerNoun()
- }
- })
+ for i := 0; i < b.N; i++ {
+ HackerNoun()
+ }
}
func ExampleHackerVerb() {
Seed(11)
fmt.Println(HackerVerb())
- // Output: synthesize
+ // Output: lock
}
func ExampleFaker_HackerVerb() {
f := New(11)
fmt.Println(f.HackerVerb())
- // Output: synthesize
+ // Output: lock
}
func BenchmarkHackerVerb(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- HackerVerb()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.HackerVerb()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.HackerVerb()
- }
- })
+ for i := 0; i < b.N; i++ {
+ HackerVerb()
+ }
}
func ExampleHackeringVerb() {
Seed(11)
fmt.Println(HackeringVerb())
- // Output: connecting
+ // Output: compressing
}
func ExampleFaker_HackeringVerb() {
f := New(11)
fmt.Println(f.HackeringVerb())
- // Output: connecting
+ // Output: compressing
}
func BenchmarkHackeringVerb(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- HackeringVerb()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.HackeringVerb()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.HackeringVerb()
- }
- })
+ for i := 0; i < b.N; i++ {
+ HackeringVerb()
+ }
}
diff --git a/helpers.go b/helpers.go
index 3dcf849b..edef038c 100644
--- a/helpers.go
+++ b/helpers.go
@@ -1,17 +1,14 @@
package gofakeit
import (
- crand "crypto/rand"
- "encoding/binary"
"encoding/json"
"fmt"
"math"
- "math/rand"
"reflect"
"strings"
"unicode"
- "github.com/brianvoe/gofakeit/v6/data"
+ "github.com/brianvoe/gofakeit/v7/data"
)
const lowerStr = "abcdefghijklmnopqrstuvwxyz"
@@ -30,16 +27,7 @@ const minUint = 0
const maxUint = ^uint(0)
const minInt = -maxInt - 1
const maxInt = int(^uint(0) >> 1)
-
-// Seed will set the global random value. Setting seed to 0 will use crypto/rand
-func Seed(seed int64) {
- if seed == 0 {
- binary.Read(crand.Reader, binary.BigEndian, &seed)
- globalFaker.Rand.Seed(seed)
- } else {
- globalFaker.Rand.Seed(seed)
- }
-}
+const is32bit = ^uint(0)>>32 == 0
// Check if in lib
func dataCheck(dataVal []string) bool {
@@ -56,40 +44,40 @@ func dataCheck(dataVal []string) bool {
}
// Get Random Value
-func getRandValue(r *rand.Rand, dataVal []string) string {
+func getRandValue(f *Faker, dataVal []string) string {
if !dataCheck(dataVal) {
return ""
}
- return data.Data[dataVal[0]][dataVal[1]][r.Intn(len(data.Data[dataVal[0]][dataVal[1]]))]
+ return data.Data[dataVal[0]][dataVal[1]][f.IntN(len(data.Data[dataVal[0]][dataVal[1]]))]
}
// Replace # with numbers
-func replaceWithNumbers(r *rand.Rand, str string) string {
+func replaceWithNumbers(f *Faker, str string) string {
if str == "" {
return str
}
bytestr := []byte(str)
for i := 0; i < len(bytestr); i++ {
if bytestr[i] == hashtag {
- bytestr[i] = byte(randDigit(r))
+ bytestr[i] = byte(randDigit(f))
}
}
if bytestr[0] == '0' {
- bytestr[0] = byte(r.Intn(8)+1) + '0'
+ bytestr[0] = byte(f.IntN(8)+1) + '0'
}
return string(bytestr)
}
// Replace ? with ASCII lowercase letters
-func replaceWithLetters(r *rand.Rand, str string) string {
+func replaceWithLetters(f *Faker, str string) string {
if str == "" {
return str
}
bytestr := []byte(str)
for i := 0; i < len(bytestr); i++ {
if bytestr[i] == questionmark {
- bytestr[i] = byte(randLetter(r))
+ bytestr[i] = byte(randLetter(f))
}
}
@@ -97,14 +85,14 @@ func replaceWithLetters(r *rand.Rand, str string) string {
}
// Replace ? with ASCII lowercase letters between a and f
-func replaceWithHexLetters(r *rand.Rand, str string) string {
+func replaceWithHexLetters(f *Faker, str string) string {
if str == "" {
return str
}
bytestr := []byte(str)
for i := 0; i < len(bytestr); i++ {
if bytestr[i] == questionmark {
- bytestr[i] = byte(randHexLetter(r))
+ bytestr[i] = byte(randHexLetter(f))
}
}
@@ -112,81 +100,51 @@ func replaceWithHexLetters(r *rand.Rand, str string) string {
}
// Generate random lowercase ASCII letter
-func randLetter(r *rand.Rand) rune {
+func randLetter(f *Faker) rune {
allLetters := upperStr + lowerStr
- return rune(allLetters[r.Intn(len(allLetters))])
+ return rune(allLetters[f.IntN(len(allLetters))])
}
-func randCharacter(r *rand.Rand, s string) string {
- return string(s[r.Int63()%int64(len(s))])
+func randCharacter(f *Faker, s string) string {
+ return string(s[f.Int64()%int64(len(s))])
}
// Generate random lowercase ASCII letter between a and f
-func randHexLetter(r *rand.Rand) rune {
- return rune(byte(r.Intn(6)) + 'a')
+func randHexLetter(f *Faker) rune {
+ return rune(byte(f.IntN(6)) + 'a')
}
// Generate random ASCII digit
-func randDigit(r *rand.Rand) rune {
- return rune(byte(r.Intn(10)) + '0')
+func randDigit(f *Faker) rune {
+ return rune(byte(f.IntN(10)) + '0')
}
// Generate random integer between min and max
-func randIntRange(r *rand.Rand, min, max int) int {
- // If they pass in the same number, just return that number
+func randIntRange(f *Faker, min, max int) int {
if min == max {
return min
}
- // If they pass in a min that is bigger than max, swap them
if min > max {
- ogmin := min
- min = max
- max = ogmin
+ min, max = max, min // Swap if min is greater than max
}
- // Figure out if the min/max numbers calculation
- // would cause a panic in the Int63() function.
- if max-min+1 > 0 {
- return min + int(r.Int63n(int64(max-min+1)))
- }
-
- // Loop through the range until we find a number that fits
- for {
- v := int(r.Uint64())
- if (v >= min) && (v <= max) {
- return v
- }
- }
+ // Use f.IntN to generate a random number in [0, rangeSize) and shift it into [min, max].
+ return f.IntN(max-min+1) + min
}
// Generate random uint between min and max
-func randUintRange(r *rand.Rand, min, max uint) uint {
- // If they pass in the same number, just return that number
+func randUintRange(f *Faker, min, max uint) uint {
if min == max {
- return min
+ return min // Immediate return if range is zero
}
- // If they pass in a min that is bigger than max, swap them
if min > max {
- ogmin := min
- min = max
- max = ogmin
- }
-
- // Figure out if the min/max numbers calculation
- // would cause a panic in the Int63() function.
- if int(max)-int(min)+1 > 0 {
- return uint(r.Intn(int(max)-int(min)+1) + int(min))
+ min, max = max, min // Swap if min is greater than max
}
- // Loop through the range until we find a number that fits
- for {
- v := uint(r.Uint64())
- if (v >= min) && (v <= max) {
- return v
- }
- }
+ // Use f.UintN to generate a random number in [0, rangeSize) and shift it into [min, max].
+ return f.UintN(max-min+1) + min
}
func toFixed(num float64, precision int) float64 {
diff --git a/helpers_test.go b/helpers_test.go
index b5bb9f65..a0624644 100644
--- a/helpers_test.go
+++ b/helpers_test.go
@@ -5,10 +5,6 @@ import (
"testing"
)
-func TestSeed(t *testing.T) {
- Seed(0)
-}
-
// Test taking in two random int values and making sure the output is within the range
func TestRandIntRange(t *testing.T) {
// Create a set of structs to test
@@ -21,6 +17,8 @@ func TestRandIntRange(t *testing.T) {
{0, 0},
{1000, -1000},
{minInt, maxInt},
+ {minInt, minInt + 100}, // Test min
+ {maxInt - 100, maxInt}, // Test max
{maxInt - 20000, maxInt - 10000},
{minInt + 10000, maxInt - 10000},
}
@@ -28,21 +26,21 @@ func TestRandIntRange(t *testing.T) {
// Add 10000 random values to the test set
for i := 0; i < 5000; i++ {
tests = append(tests, testStruct{
- min: randIntRange(globalFaker.Rand, 0, maxInt),
- max: randIntRange(globalFaker.Rand, 0, maxInt),
+ min: randIntRange(GlobalFaker, 0, maxInt),
+ max: randIntRange(GlobalFaker, 0, maxInt),
})
}
for i := 0; i < 5000; i++ {
tests = append(tests, testStruct{
- min: randIntRange(globalFaker.Rand, minInt, 0),
- max: randIntRange(globalFaker.Rand, 0, maxInt),
+ min: randIntRange(GlobalFaker, minInt, 0),
+ max: randIntRange(GlobalFaker, 0, maxInt),
})
}
// Loop through the tests
for _, test := range tests {
// Get the result
- result := randIntRange(globalFaker.Rand, test.min, test.max)
+ result := randIntRange(GlobalFaker, test.min, test.max)
// Check the result
if test.min > test.max {
@@ -67,28 +65,28 @@ func TestRandUintRange(t *testing.T) {
tests := []testStruct{
{0, 0},
{100000, 100},
- {0, maxUint},
- {0 + 10000, maxUint - 10000},
+ {minUint, maxUint},
+ {minUint + 10000, maxUint - 10000},
}
// Add 10000 random values to the test set
for i := 0; i < 5000; i++ {
tests = append(tests, testStruct{
- min: randUintRange(globalFaker.Rand, 0, maxUint),
- max: randUintRange(globalFaker.Rand, 0, maxUint),
+ min: randUintRange(GlobalFaker, 0, maxUint),
+ max: randUintRange(GlobalFaker, 0, maxUint),
})
}
for i := 0; i < 5000; i++ {
tests = append(tests, testStruct{
- min: randUintRange(globalFaker.Rand, 0, maxUint/2),
- max: randUintRange(globalFaker.Rand, maxUint/2, maxUint),
+ min: randUintRange(GlobalFaker, 0, maxUint/2),
+ max: randUintRange(GlobalFaker, maxUint/2, maxUint),
})
}
// Loop through the tests
for _, test := range tests {
// Get the result
- result := randUintRange(globalFaker.Rand, test.min, test.max)
+ result := randUintRange(GlobalFaker, test.min, test.max)
// Check the result
if test.min > test.max {
@@ -104,49 +102,54 @@ func TestRandUintRange(t *testing.T) {
func TestGetRandValueFail(t *testing.T) {
for _, test := range [][]string{nil, {}, {"not", "found"}, {"person", "notfound"}} {
- if getRandValue(globalFaker.Rand, test) != "" {
+ if getRandValue(GlobalFaker, test) != "" {
t.Error("You should have gotten no value back")
}
}
}
func TestReplaceWithNumbers(t *testing.T) {
- if replaceWithNumbers(globalFaker.Rand, "") != "" {
+ if replaceWithNumbers(GlobalFaker, "") != "" {
t.Error("You should have gotten an empty string")
}
}
func BenchmarkReplaceWithNumbers(b *testing.B) {
for i := 0; i < b.N; i++ {
- Seed(42)
- replaceWithNumbers(globalFaker.Rand, "###☺#☻##☹##")
+ Seed(11)
+ replaceWithNumbers(GlobalFaker, "###☺#☻##☹##")
}
}
func TestReplaceWithNumbersUnicode(t *testing.T) {
- for _, test := range []struct{ in, should string }{
- {"#界#世#", "5界7世8"},
- {"☺#☻☹#", "☺5☻☹7"},
- {"\x80#¼#語", "\x805¼7語"},
+ for _, test := range []struct{ in string }{
+ {"#界#世#"},
+ {"☺#☻☹#"},
+ {"\x80#¼#語"},
} {
- Seed(42)
- got := replaceWithNumbers(globalFaker.Rand, test.in)
- if got == test.should {
- continue
+ Seed(11)
+ got := replaceWithNumbers(GlobalFaker, test.in)
+ if got == test.in {
+ t.Errorf("got %q, want something different", got)
+ }
+
+ // Check that # were replaced with numbers
+ for _, r := range got {
+ if r == '#' {
+ t.Errorf("got %q, want something different", got)
+ }
}
- t.Errorf("for '%s' got '%s' should '%s'",
- test.in, got, test.should)
}
}
func TestReplaceWithLetters(t *testing.T) {
- if replaceWithLetters(globalFaker.Rand, "") != "" {
+ if replaceWithLetters(GlobalFaker, "") != "" {
t.Error("You should have gotten an empty string")
}
}
func TestReplaceWithHexLetters(t *testing.T) {
- if replaceWithHexLetters(globalFaker.Rand, "") != "" {
+ if replaceWithHexLetters(GlobalFaker, "") != "" {
t.Error("You should have gotten an empty string")
}
}
diff --git a/hipster.go b/hipster.go
index 0369f17e..8cf7cba9 100644
--- a/hipster.go
+++ b/hipster.go
@@ -2,25 +2,24 @@ package gofakeit
import (
"errors"
- "math/rand"
)
// HipsterWord will return a single hipster word
-func HipsterWord() string { return hipsterWord(globalFaker.Rand) }
+func HipsterWord() string { return hipsterWord(GlobalFaker) }
// HipsterWord will return a single hipster word
-func (f *Faker) HipsterWord() string { return hipsterWord(f.Rand) }
+func (f *Faker) HipsterWord() string { return hipsterWord(f) }
-func hipsterWord(r *rand.Rand) string { return getRandValue(r, []string{"hipster", "word"}) }
+func hipsterWord(f *Faker) string { return getRandValue(f, []string{"hipster", "word"}) }
// HipsterSentence will generate a random sentence
-func HipsterSentence(wordCount int) string { return hipsterSentence(globalFaker.Rand, wordCount) }
+func HipsterSentence(wordCount int) string { return hipsterSentence(GlobalFaker, wordCount) }
// HipsterSentence will generate a random sentence
-func (f *Faker) HipsterSentence(wordCount int) string { return hipsterSentence(f.Rand, wordCount) }
+func (f *Faker) HipsterSentence(wordCount int) string { return hipsterSentence(f, wordCount) }
-func hipsterSentence(r *rand.Rand, wordCount int) string {
- return sentenceGen(r, wordCount, hipsterWord)
+func hipsterSentence(f *Faker, wordCount int) string {
+ return sentenceGen(f, wordCount, hipsterWord)
}
// HipsterParagraph will generate a random paragraphGenerator
@@ -29,7 +28,7 @@ func hipsterSentence(r *rand.Rand, wordCount int) string {
// Set Word Count
// Set Paragraph Separator
func HipsterParagraph(paragraphCount int, sentenceCount int, wordCount int, separator string) string {
- return hipsterParagraph(globalFaker.Rand, paragraphCount, sentenceCount, wordCount, separator)
+ return hipsterParagraph(GlobalFaker, paragraphCount, sentenceCount, wordCount, separator)
}
// HipsterParagraph will generate a random paragraphGenerator
@@ -38,11 +37,11 @@ func HipsterParagraph(paragraphCount int, sentenceCount int, wordCount int, sepa
// Set Word Count
// Set Paragraph Separator
func (f *Faker) HipsterParagraph(paragraphCount int, sentenceCount int, wordCount int, separator string) string {
- return hipsterParagraph(f.Rand, paragraphCount, sentenceCount, wordCount, separator)
+ return hipsterParagraph(f, paragraphCount, sentenceCount, wordCount, separator)
}
-func hipsterParagraph(r *rand.Rand, paragraphCount int, sentenceCount int, wordCount int, separator string) string {
- return paragraphGen(r, paragrapOptions{paragraphCount, sentenceCount, wordCount, separator}, hipsterSentence)
+func hipsterParagraph(f *Faker, paragraphCount int, sentenceCount int, wordCount int, separator string) string {
+ return paragraphGen(f, paragrapOptions{paragraphCount, sentenceCount, wordCount, separator}, hipsterSentence)
}
func addHipsterLookup() {
@@ -52,8 +51,8 @@ func addHipsterLookup() {
Description: "Trendy and unconventional vocabulary used by hipsters to express unique cultural preferences",
Example: "microdosing",
Output: "string",
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
- return hipsterWord(r), nil
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
+ return hipsterWord(f), nil
},
})
@@ -66,7 +65,7 @@ func addHipsterLookup() {
Params: []Param{
{Field: "wordcount", Display: "Word Count", Type: "int", Default: "5", Description: "Number of words in a sentence"},
},
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
wordCount, err := info.GetInt(m, "wordcount")
if err != nil {
return nil, err
@@ -75,7 +74,7 @@ func addHipsterLookup() {
return nil, errors.New("invalid word count, must be greater than 0, less than 50")
}
- return hipsterSentence(r, wordCount), nil
+ return hipsterSentence(f, wordCount), nil
},
})
@@ -95,7 +94,7 @@ Shabby chic typewriter VHS readymade lo-fi bitters PBR&B gentrify lomo raw denim
{Field: "wordcount", Display: "Word Count", Type: "int", Default: "5", Description: "Number of words in a sentence"},
{Field: "paragraphseparator", Display: "Paragraph Separator", Type: "string", Default: "
", Description: "String value to add between paragraphs"},
},
- Generate: func(r *rand.Rand, m *MapParams, info *Info) (any, error) {
+ Generate: func(f *Faker, m *MapParams, info *Info) (any, error) {
paragraphCount, err := info.GetInt(m, "paragraphcount")
if err != nil {
return nil, err
@@ -125,7 +124,7 @@ Shabby chic typewriter VHS readymade lo-fi bitters PBR&B gentrify lomo raw denim
return nil, err
}
- return hipsterParagraph(r, paragraphCount, sentenceCount, wordCount, paragraphSeparator), nil
+ return hipsterParagraph(f, paragraphCount, sentenceCount, wordCount, paragraphSeparator), nil
},
})
}
diff --git a/hipster_test.go b/hipster_test.go
index 564ad0f7..277c9eda 100644
--- a/hipster_test.go
+++ b/hipster_test.go
@@ -9,116 +9,62 @@ func ExampleHipsterWord() {
Seed(11)
fmt.Println(HipsterWord())
- // Output: microdosing
+ // Output: semiotics
}
func ExampleFaker_HipsterWord() {
f := New(11)
fmt.Println(f.HipsterWord())
- // Output: microdosing
+ // Output: semiotics
}
func BenchmarkHipsterWord(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- HipsterWord()
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.HipsterWord()
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.HipsterWord()
- }
- })
+ for i := 0; i < b.N; i++ {
+ HipsterWord()
+ }
}
func ExampleHipsterSentence() {
Seed(11)
fmt.Println(HipsterSentence(5))
- // Output: Microdosing roof chia echo pickled.
+ // Output: Semiotics everyday you probably haven't heard of them you probably haven't heard of them portland.
}
func ExampleFaker_HipsterSentence() {
f := New(11)
fmt.Println(f.HipsterSentence(5))
- // Output: Microdosing roof chia echo pickled.
+ // Output: Semiotics everyday you probably haven't heard of them you probably haven't heard of them portland.
}
func BenchmarkHipsterSentence(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- HipsterSentence(10)
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.HipsterSentence(10)
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.HipsterSentence(10)
- }
- })
+ for i := 0; i < b.N; i++ {
+ HipsterSentence(10)
+ }
}
func ExampleHipsterParagraph() {
Seed(11)
fmt.Println(HipsterParagraph(3, 5, 12, "\n"))
- // Output: Microdosing roof chia echo pickled meditation cold-pressed raw denim fingerstache normcore sriracha pork belly. Wolf try-hard pop-up blog tilde hashtag health butcher waistcoat paleo portland vinegar. Microdosing sartorial blue bottle slow-carb freegan five dollar toast you probably haven't heard of them asymmetrical chia farm-to-table narwhal banjo. Gluten-free blog authentic literally synth vinyl meh ethical health fixie banh mi Yuccie. Try-hard drinking squid seitan cray VHS echo chillwave hammock kombucha food truck sustainable.
- // Pug bushwick hella tote bag cliche direct trade waistcoat yr waistcoat knausgaard pour-over master. Pitchfork jean shorts franzen flexitarian distillery hella meggings austin knausgaard crucifix wolf heirloom. Crucifix food truck you probably haven't heard of them trust fund fixie gentrify pitchfork stumptown mlkshk umami chambray blue bottle. 3 wolf moon swag +1 biodiesel knausgaard semiotics taxidermy meh artisan hoodie +1 blue bottle. Fashion axe forage mixtape Thundercats pork belly whatever 90's beard selfies chambray cred mlkshk.
- // Shabby chic typewriter VHS readymade lo-fi bitters PBR&B gentrify lomo raw denim freegan put a bird on it. Raw denim cliche dreamcatcher pug fixie park trust fund migas fingerstache sriracha +1 mustache. Tilde shoreditch kickstarter franzen dreamcatcher green juice mustache neutra polaroid stumptown organic schlitz. Flexitarian ramps chicharrones kogi lo-fi mustache tilde forage street church-key williamsburg taxidermy. Chia mustache plaid mumblecore squid slow-carb disrupt Thundercats goth shoreditch master direct trade.
+ // Output: Semiotics everyday you probably haven't heard of them you probably haven't heard of them portland austin tattooed retro cardigan Yuccie cred hoodie. Vice pug pug cred intelligentsia roof helvetica squid chambray literally ennui ugh. Chicharrones messenger bag narwhal ennui flannel twee art party mustache sartorial gluten-free cardigan cronut. Hoodie kickstarter cardigan Thundercats heirloom hashtag bitters salvia cleanse forage chartreuse keffiyeh. Sustainable tofu mustache bespoke vice aesthetic iPhone ugh lo-fi health put a bird on it blue bottle.
+ // Pop-up pabst pitchfork literally roof tattooed tilde shoreditch green juice ethical celiac tilde. Kombucha kinfolk occupy tacos ramps 90's echo meditation kale chips gluten-free humblebrag keffiyeh. Lo-fi bespoke wayfarers chicharrones crucifix green juice humblebrag organic viral shabby chic locavore cred. Roof forage farm-to-table YOLO williamsburg crucifix blog everyday green juice listicle wayfarers post-ironic. Single-origin coffee cray organic YOLO disrupt venmo tofu meggings fanny pack master craft beer tofu.
+ // Hella helvetica microdosing literally meh etsy echo pabst goth readymade +1 marfa. Pork belly hammock kale chips yr green juice stumptown crucifix hella pork belly franzen wolf austin. Offal cred chartreuse freegan intelligentsia twee trust fund paleo pinterest austin typewriter kogi. Pug single-origin coffee ethical irony helvetica beard green juice viral post-ironic Godard slow-carb put a bird on it. Schlitz hammock beard chia kitsch cred salvia irony farm-to-table loko truffaut ramps.
}
func ExampleFaker_HipsterParagraph() {
f := New(11)
fmt.Println(f.HipsterParagraph(3, 5, 12, "\n"))
- // Output: Microdosing roof chia echo pickled meditation cold-pressed raw denim fingerstache normcore sriracha pork belly. Wolf try-hard pop-up blog tilde hashtag health butcher waistcoat paleo portland vinegar. Microdosing sartorial blue bottle slow-carb freegan five dollar toast you probably haven't heard of them asymmetrical chia farm-to-table narwhal banjo. Gluten-free blog authentic literally synth vinyl meh ethical health fixie banh mi Yuccie. Try-hard drinking squid seitan cray VHS echo chillwave hammock kombucha food truck sustainable.
- // Pug bushwick hella tote bag cliche direct trade waistcoat yr waistcoat knausgaard pour-over master. Pitchfork jean shorts franzen flexitarian distillery hella meggings austin knausgaard crucifix wolf heirloom. Crucifix food truck you probably haven't heard of them trust fund fixie gentrify pitchfork stumptown mlkshk umami chambray blue bottle. 3 wolf moon swag +1 biodiesel knausgaard semiotics taxidermy meh artisan hoodie +1 blue bottle. Fashion axe forage mixtape Thundercats pork belly whatever 90's beard selfies chambray cred mlkshk.
- // Shabby chic typewriter VHS readymade lo-fi bitters PBR&B gentrify lomo raw denim freegan put a bird on it. Raw denim cliche dreamcatcher pug fixie park trust fund migas fingerstache sriracha +1 mustache. Tilde shoreditch kickstarter franzen dreamcatcher green juice mustache neutra polaroid stumptown organic schlitz. Flexitarian ramps chicharrones kogi lo-fi mustache tilde forage street church-key williamsburg taxidermy. Chia mustache plaid mumblecore squid slow-carb disrupt Thundercats goth shoreditch master direct trade.
+ // Output: Semiotics everyday you probably haven't heard of them you probably haven't heard of them portland austin tattooed retro cardigan Yuccie cred hoodie. Vice pug pug cred intelligentsia roof helvetica squid chambray literally ennui ugh. Chicharrones messenger bag narwhal ennui flannel twee art party mustache sartorial gluten-free cardigan cronut. Hoodie kickstarter cardigan Thundercats heirloom hashtag bitters salvia cleanse forage chartreuse keffiyeh. Sustainable tofu mustache bespoke vice aesthetic iPhone ugh lo-fi health put a bird on it blue bottle.
+ // Pop-up pabst pitchfork literally roof tattooed tilde shoreditch green juice ethical celiac tilde. Kombucha kinfolk occupy tacos ramps 90's echo meditation kale chips gluten-free humblebrag keffiyeh. Lo-fi bespoke wayfarers chicharrones crucifix green juice humblebrag organic viral shabby chic locavore cred. Roof forage farm-to-table YOLO williamsburg crucifix blog everyday green juice listicle wayfarers post-ironic. Single-origin coffee cray organic YOLO disrupt venmo tofu meggings fanny pack master craft beer tofu.
+ // Hella helvetica microdosing literally meh etsy echo pabst goth readymade +1 marfa. Pork belly hammock kale chips yr green juice stumptown crucifix hella pork belly franzen wolf austin. Offal cred chartreuse freegan intelligentsia twee trust fund paleo pinterest austin typewriter kogi. Pug single-origin coffee ethical irony helvetica beard green juice viral post-ironic Godard slow-carb put a bird on it. Schlitz hammock beard chia kitsch cred salvia irony farm-to-table loko truffaut ramps.
}
func BenchmarkHipsterParagraph(b *testing.B) {
- b.Run("package", func(b *testing.B) {
- for i := 0; i < b.N; i++ {
- HipsterParagraph(3, 5, 12, "\n")
- }
- })
-
- b.Run("Faker math", func(b *testing.B) {
- f := New(0)
-
- for i := 0; i < b.N; i++ {
- f.HipsterParagraph(3, 5, 12, "\n")
- }
- })
-
- b.Run("Faker crypto", func(b *testing.B) {
- f := NewCrypto()
-
- for i := 0; i < b.N; i++ {
- f.HipsterParagraph(3, 5, 12, "\n")
- }
- })
+ for i := 0; i < b.N; i++ {
+ HipsterParagraph(3, 5, 12, "\n")
+ }
}
diff --git a/html.go b/html.go
index a047617a..27385ecd 100644
--- a/html.go
+++ b/html.go
@@ -2,25 +2,24 @@ package gofakeit
import (
"errors"
- "math/rand"
"strconv"
"strings"
- "github.com/brianvoe/gofakeit/v6/data"
+ "github.com/brianvoe/gofakeit/v7/data"
)
// InputName will return a random input field name
func InputName() string {
- return inputName(globalFaker.Rand)
+ return inputName(GlobalFaker)
}
// InputName will return a random input field name
func (f *Faker) InputName() string {
- return inputName(f.Rand)
+ return inputName(f)
}
-func inputName(r *rand.Rand) string {
- return getRandValue(r, []string{"html", "input_name"})
+func inputName(f *Faker) string {
+ return getRandValue(f, []string{"html", "input_name"})
}
type SVGOptions struct {
@@ -31,12 +30,12 @@ type SVGOptions struct {
}
// Generate a random svg generator
-func Svg(options *SVGOptions) string { return svg(globalFaker.Rand, options) }
+func Svg(options *SVGOptions) string { return svg(GlobalFaker, options) }
// Generate a random svg generator
-func (f *Faker) Svg(options *SVGOptions) string { return svg(f.Rand, options) }
+func (f *Faker) Svg(options *SVGOptions) string { return svg(f, options) }
-func svg(r *rand.Rand, options *SVGOptions) string {
+func svg(f *Faker, options *SVGOptions) string {
// If options is nil, set it to empty struct
if options == nil {
options = &SVGOptions{}
@@ -44,46 +43,46 @@ func svg(r *rand.Rand, options *SVGOptions) string {
// If options height and weight is not set, set it to random number between 100 and 500
if options.Width == 0 {
- options.Width = number(r, 100, 500)
+ options.Width = number(f, 100, 500)
}
widthStr := strconv.Itoa(options.Width)
if options.Height == 0 {
- options.Height = number(r, 100, 500)
+ options.Height = number(f, 100, 500)
}
heightStr := strconv.Itoa(options.Height)
// Check if type is set, if not set to random type
if options.Type == "" {
- options.Type = randomString(r, data.GetSubData("html", "svg"))
+ options.Type = randomString(f, data.GetSubData("html", "svg"))
}
// If the colors are not set, set it to a set of nice colors
if len(options.Colors) == 0 {
- options.Colors = niceColors(r)
+ options.Colors = niceColors(f)
}
// Start svg string
svgStr := `