diff options
author | silverwind <me@silverwind.io> | 2022-05-10 23:55:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-10 23:55:54 +0200 |
commit | 318f360252777c6eb819ab206a1f276fa4969f3a (patch) | |
tree | 7a73ede2df5b52be940dd9b4005137c1d5d53c04 /modules/util | |
parent | 3c658dff233e791856496761325f5ebf787d7521 (diff) | |
download | gitea-318f360252777c6eb819ab206a1f276fa4969f3a.tar.gz gitea-318f360252777c6eb819ab206a1f276fa4969f3a.zip |
Update go tool dependencies (#19676)
* Update go tool dependencies
Updated all tool dependencies to latest tags, hoping CI will like it.
* fix new lint errors
* handle more strings.Title cases
* remove lint skip
Diffstat (limited to 'modules/util')
-rw-r--r-- | modules/util/util.go | 10 | ||||
-rw-r--r-- | modules/util/util_test.go | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/modules/util/util.go b/modules/util/util.go index af6581f7cd..351a345473 100644 --- a/modules/util/util.go +++ b/modules/util/util.go @@ -11,6 +11,9 @@ import ( "math/big" "strconv" "strings" + + "golang.org/x/text/cases" + "golang.org/x/text/language" ) // OptionalBool a boolean that can be "null" @@ -181,3 +184,10 @@ func ToUpperASCII(s string) string { } return string(b) } + +var titleCaser = cases.Title(language.English) + +// ToTitleCase returns s with all english words capitalized +func ToTitleCase(s string) string { + return titleCaser.String(s) +} diff --git a/modules/util/util_test.go b/modules/util/util_test.go index 0c2792a9cb..ca5bd87eae 100644 --- a/modules/util/util_test.go +++ b/modules/util/util_test.go @@ -220,3 +220,8 @@ func BenchmarkToUpper(b *testing.B) { }) } } + +func TestToTitleCase(t *testing.T) { + assert.Equal(t, ToTitleCase(`foo bar baz`), `Foo Bar Baz`) + assert.Equal(t, ToTitleCase(`FOO BAR BAZ`), `Foo Bar Baz`) +} |