Is there any go package that receives a regex as input and returns a random string matching that regex or can you direct me how such a solution can be implemented?
My first thought is to generate random bytes in a loop from /dev/rand and then return one that matches the regex but I think this kind of brute-force would be time consuming until I find one such string matching the regex.
Use case:
I'm planning to use this for a web service testing library.
Some API calls such registering an user account requires unique fields such an email address, phone number etc thus the need of a random input generator based on a patter/regex.
The random property also helps to safeguard against stale data /false positives (i.e. data that was stored before the current test suite). I guess the generator doesn't need to provide cryptography level randomness but rather something like GUID.