Skip to content

Commit e00313f

Browse files
authored
[chore] initialize regexps with MustCompile, simplify init (#3641)
1 parent b56983d commit e00313f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

internal/naming/triming.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ import (
2222
"regexp"
2323
)
2424

25-
var regexpEndReplace, regexpBeginReplace *regexp.Regexp
26-
27-
func init() {
28-
regexpEndReplace, _ = regexp.Compile("[^A-Za-z0-9]+$")
29-
regexpBeginReplace, _ = regexp.Compile("^[^A-Za-z0-9]+")
30-
}
25+
var (
26+
regexpEndReplace = regexp.MustCompile("[^A-Za-z0-9]+$")
27+
regexpBeginReplace = regexp.MustCompile("^[^A-Za-z0-9]+")
28+
)
3129

3230
// Truncate will shorten the length of the instance name so that it contains at most max chars when combined with the fixed part
3331
// If the fixed part is already bigger than the max, this function is noop.

0 commit comments

Comments
 (0)