Currently, IsHash() parses, compiles and matches a regular expression each time, which is highly inefficient in terms of CPU and RAM. Instead, it should check the length of str and then iterate over str to check the digits, which will be a lot faster and won't allocate any memory at all.
https://github.com/asaskevich/govalidator/blob/a9d515a09cc289c60d55064edec5ef189859f172/validator.go#L708
Currently,
IsHash()
parses, compiles and matches a regular expression each time, which is highly inefficient in terms of CPU and RAM. Instead, it should check the length ofstr
and then iterate overstr
to check the digits, which will be a lot faster and won't allocate any memory at all.