Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] initialize regexps with MustCompile, simplify init #3641

Merged
merged 1 commit into from
Jan 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading