From 318f360252777c6eb819ab206a1f276fa4969f3a Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 10 May 2022 23:55:54 +0200 Subject: 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 --- modules/util/util.go | 10 ++++++++++ modules/util/util_test.go | 5 +++++ 2 files changed, 15 insertions(+) (limited to 'modules/util') 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`) +} -- cgit v1.2.3