Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Apr 3, 2023
1 parent 977ef21 commit d70f79b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions modules/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,16 @@ func ToUpperASCII(s string) string {
return string(b)
}

var (
titleCaser = cases.Title(language.English)
titleCaserNoLower = cases.Title(language.English, cases.NoLower)
)

// ToTitleCase returns s with all english words capitalized
func ToTitleCase(s string) string {
return titleCaser.String(s)
// `cases.Title` is not thread-safe, do not use global shared variable for it
return cases.Title(language.English).String(s)
}

// ToTitleCaseNoLower returns s with all english words capitalized without lowercasing
// ToTitleCaseNoLower returns s with all english words capitalized without lower-casing
func ToTitleCaseNoLower(s string) string {
return titleCaserNoLower.String(s)
// `cases.Title` is not thread-safe, do not use global shared variable for it
return cases.Title(language.English, cases.NoLower).String(s)
}

var (
Expand Down

0 comments on commit d70f79b

Please sign in to comment.