The signature for assert.Regexp (and associated methods) is:
func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool {
However, these methods immediately call matchRegexp, which is this:
func matchRegexp(rx interface{}, str interface{}) bool {
var r *regexp.Regexp
if rr, ok := rx.(*regexp.Regexp); ok {
r = rr
} else {
r = regexp.MustCompile(fmt.Sprint(rx))
}
return (r.FindStringIndex(fmt.Sprint(str)) != nil)
}
Given this - wouldn't it make more sense for the signature to just be *regexp.Regexp and string ? The latter cast would likely help prevent unexpected behavior around the fmt.Sprint call.
The signature for
assert.Regexp(and associated methods) is:However, these methods immediately call
matchRegexp, which is this:Given this - wouldn't it make more sense for the signature to just be
*regexp.Regexpandstring? The latter cast would likely help prevent unexpected behavior around thefmt.Sprintcall.