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.
This commit is contained in:
albertony 2022-06-24 16:33:45 +02:00
parent 7822df565e
commit 5b579cea47
2 changed files with 7 additions and 2 deletions

View File

@ -17,6 +17,8 @@ import (
"github.com/rclone/rclone/lib/atexit" "github.com/rclone/rclone/lib/atexit"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/pflag" "github.com/spf13/pflag"
"golang.org/x/text/cases"
"golang.org/x/text/language"
) )
// Root is the main rclone command // Root is the main rclone command
@ -316,7 +318,8 @@ func showBackend(name string) {
optionsType = "advanced" optionsType = "advanced"
continue 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) fmt.Printf("Here are the %s options specific to %s (%s).\n\n", optionsType, backend.Name, backend.Description)
optionsType = "advanced" optionsType = "advanced"
for _, opt := range opts { for _, opt := range opts {

View File

@ -47,6 +47,8 @@ import (
"github.com/rclone/rclone/fstest/fstests" "github.com/rclone/rclone/fstest/fstests"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/text/cases"
"golang.org/x/text/language"
) )
// Some times used in the tests // Some times used in the tests
@ -270,7 +272,7 @@ func TestHashSums(t *testing.T) {
if !hashes.Contains(test.ht) { if !hashes.Contains(test.ht) {
continue continue
} }
name := strings.Title(test.ht.String()) name := cases.Title(language.Und, cases.NoLower).String(test.ht.String())
if test.download { if test.download {
name += "Download" name += "Download"
} }