Skip to content

Commit af43dfb

Browse files
fixing race condition issue
1 parent c943f65 commit af43dfb

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

styling/styling.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ func StripANSI(input string) string {
8181
return ansiRegex.ReplaceAllString(input, "")
8282
}
8383

84-
// titleCaser is a reusable title caser for English
85-
var titleCaser = cases.Title(language.English)
86-
8784
// smallWords are words that should remain lowercase in titles (unless first word)
8885
var smallWords = map[string]bool{
8986
"of": true,
@@ -95,14 +92,16 @@ var smallWords = map[string]bool{
9592
// CapitalizeResourceName converts hyphenated resource names to title case
9693
// Example: "strong-jaw" -> "Strong Jaw", "sword-of-ruin" -> "Sword of Ruin"
9794
func CapitalizeResourceName(name string) string {
95+
caser := cases.Title(language.English)
96+
9897
name = strings.ReplaceAll(name, "-", " ")
9998
words := strings.Split(name, " ")
10099

101100
for i, word := range words {
102101
if _, found := smallWords[strings.ToLower(word)]; found && i != 0 {
103102
words[i] = strings.ToLower(word)
104103
} else {
105-
words[i] = titleCaser.String(word)
104+
words[i] = caser.String(word)
106105
}
107106
}
108107

0 commit comments

Comments
 (0)