./github.com/asaskevich/govalidator/utils.go:156:21: regexpMust: for const patterns like `[ &_=+:]`, use regexp.MustCompile
./github.com/asaskevich/govalidator/utils.go:160:16: regexpMust: for const patterns like `[^[:alnum:]-.]`, use regexp.MustCompile
Since the pattern is constant, one might want to use regexp.MustCompile there and avoid the awkward err == nil branch. If there is an error in pattern, it should be fixed inside a source code.
As a side note, regexp compilation should probably be moved to outside of the function if it's called multiple times. Compilation is a slow operation for regexp pacakge.
Hello guys!
I forked this package cause owner disappeared. Hope, he will be back, but it would be easier to merge these changes back if he is back
Link to my repo: create issue there and we'll discuss it.
https://github.com/asaskevich/govalidator/blob/f9ffefc3facfbe0caee3fea233cbb6e8208f4541/utils.go#L156-L159
Since the pattern is constant, one might want to use
regexp.MustCompile
there and avoid the awkwarderr == nil
branch. If there is an error in pattern, it should be fixed inside a source code.As a side note, regexp compilation should probably be moved to outside of the function if it's called multiple times. Compilation is a slow operation for regexp pacakge.