diff --git a/v2/internal/controllers/samples_test.go b/v2/internal/controllers/samples_test.go index 001065067cd..ce5b6a94934 100644 --- a/v2/internal/controllers/samples_test.go +++ b/v2/internal/controllers/samples_test.go @@ -14,6 +14,8 @@ import ( "testing" . "github.com/onsi/gomega" + "golang.org/x/text/cases" + "golang.org/x/text/language" v1 "k8s.io/api/core/v1" "sigs.k8s.io/controller-runtime/pkg/client" @@ -193,8 +195,9 @@ func getTestName(group string, version string) string { result.WriteString("Test_") // Titlecase for each part of the group + title := cases.Title(language.English) for _, part := range strings.Split(group, ".") { - result.WriteString(strings.Title(part)) + result.WriteString(title.String(part)) } result.WriteString("_") diff --git a/v2/tools/generator/internal/astmodel/identifier_factory.go b/v2/tools/generator/internal/astmodel/identifier_factory.go index 3452fc5b111..f04181b5d01 100644 --- a/v2/tools/generator/internal/astmodel/identifier_factory.go +++ b/v2/tools/generator/internal/astmodel/identifier_factory.go @@ -12,6 +12,8 @@ import ( "unicode" "github.com/Azure/azure-service-operator/v2/internal/set" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) // \W is all non-word characters (https://golang.org/pkg/regexp/syntax/) @@ -176,18 +178,13 @@ func (factory *identifierFactory) cleanPart(part string, visibility Visibility) clean := filterRegex.ReplaceAllLiteralString(part, " ") cleanWords := sliceIntoWords(clean) caseCorrectedWords := make([]string, 0, len(cleanWords)) + title := cases.Title(language.English, cases.NoLower) for ix, word := range cleanWords { var w string if ix == 0 && visibility == NotExported { w = strings.ToLower(word) } else { - // Disable lint: the suggested "replacement" for this in /x/cases has fundamental - // differences in how it works (e.g. 'JSON' becomes 'Json'; we don’t want that). - // Furthermore, the cases (ha) that it "fixes" are not relevant to us - // (something about better handling of various punctuation characters; - // our words are punctuation-free). - //nolint:staticcheck - w = strings.Title(word) + w = title.String(word) } caseCorrectedWords = append(caseCorrectedWords, w)