Default severity: warning
The package-level regexp matching helpers compile their pattern on every call. Calling them with a constant pattern inside a loop repeats the same compilation. Compile the expression once before the loop and reuse it.
Dynamic patterns are accepted because hoisting them may change behavior.
Bad
for _, value := range values { regexp.MatchString(`^[a-z]+$`, value) }Good
pattern := regexp.MustCompile(`^[a-z]+$`); for _, value := range values { pattern.MatchString(value) }