From d70f79befd9e8d7619a033fa1e9cb58a9d4da371 Mon Sep 17 00:00:00 2001
From: wxiaoguang <wxiaoguang@gmail.com>
Date: Mon, 3 Apr 2023 12:39:54 +0800
Subject: [PATCH] fix

---
 modules/util/util.go | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/modules/util/util.go b/modules/util/util.go
index 9d3a8dcfac219..b2800d6a0c15e 100644
--- a/modules/util/util.go
+++ b/modules/util/util.go
@@ -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 (