Skip to content

Commit

Permalink
[chore] initialize regexps with MustCompile, simplify init
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Jan 20, 2025
1 parent a36367b commit fe0a161
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions internal/naming/triming.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ import (
"regexp"
)

var regexpEndReplace, regexpBeginReplace *regexp.Regexp

func init() {
regexpEndReplace, _ = regexp.Compile("[^A-Za-z0-9]+$")
regexpBeginReplace, _ = regexp.Compile("^[^A-Za-z0-9]+")
}
var (
regexpEndReplace = regexp.MustCompile("[^A-Za-z0-9]+$")
regexpBeginReplace = regexp.MustCompile("^[^A-Za-z0-9]+")
)

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

0 comments on commit fe0a161

Please sign in to comment.