From 5b579cea47ce46fef393336042b4f1b8184c2640 Mon Sep 17 00:00:00 2001 From: albertony <12441419+albertony@users.noreply.github.com> Date: Fri, 24 Jun 2022 16:33:45 +0200 Subject: [PATCH] staticcheck: use golang.org/x/text/cases instead of deprecated strings.Title strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0. The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. --- cmd/help.go | 5 ++++- fs/operations/operations_test.go | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/help.go b/cmd/help.go index b5f1c2227..0d1295d34 100644 --- a/cmd/help.go +++ b/cmd/help.go @@ -17,6 +17,8 @@ import ( "github.com/rclone/rclone/lib/atexit" "github.com/spf13/cobra" "github.com/spf13/pflag" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) // Root is the main rclone command @@ -316,7 +318,8 @@ func showBackend(name string) { optionsType = "advanced" continue } - fmt.Printf("### %s options\n\n", strings.Title(optionsType)) + optionsType = cases.Title(language.Und, cases.NoLower).String(optionsType) + fmt.Printf("### %s options\n\n", optionsType) fmt.Printf("Here are the %s options specific to %s (%s).\n\n", optionsType, backend.Name, backend.Description) optionsType = "advanced" for _, opt := range opts { diff --git a/fs/operations/operations_test.go b/fs/operations/operations_test.go index 8cd7296e4..34b88d6d1 100644 --- a/fs/operations/operations_test.go +++ b/fs/operations/operations_test.go @@ -47,6 +47,8 @@ import ( "github.com/rclone/rclone/fstest/fstests" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) // Some times used in the tests @@ -270,7 +272,7 @@ func TestHashSums(t *testing.T) { if !hashes.Contains(test.ht) { continue } - name := strings.Title(test.ht.String()) + name := cases.Title(language.Und, cases.NoLower).String(test.ht.String()) if test.download { name += "Download" }