Lazily initialize regexes to speed up `init()`
Using GODEBUG=inittrace=1 I found a relatively constant 10ms init caused by this function.
@go-playground/validator-maintainers
coverage: 74.228% (+0.02%) from 74.208% when pulling cebbc77c0ece34053127ee5adcafd819343143a0 on kylecarbs:master into a0f74b0fb2a7ae1750c0f0b0a49550d8b6e2e708 on go-playground:master.
@kylecarbs out of curiosity, what is your use case where 10ms is not tolerable?
@deankarn this package is imported in our CLI. Adding that overhead to every invocation (even help) isn't great.
@deankarn any changes needed for me to push this through?
@kylecarbs sorry for the lateness of my reply, been busy.
My only concern is the sync.Mutex overhead for longer running applications, can you change the implementation to use sync.Once instead which uses lower level atomics?
@deankarn good idea. Will change in a bit!
I will check back later tonight/tomorrow :)