Skip to content

Commit

Permalink
staticcheck: ignore "SA1019: strings.Title is deprecated"
Browse files Browse the repository at this point in the history
This function is marked deprecated in Go 1.18; however, the suggested replacement
brings in a large amount of new code, and most strings we generate will be ASCII,
so this would only be in case it's used for some user-provided string. We also
don't have a language to use, so would be using the "default".

Adding a `//nolint` comment to suppress the linting failure instead.

    daemon/logger/templates/templates.go:23:14: SA1019: strings.Title is deprecated: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)
        "title":    strings.Title,
                    ^
    pkg/plugins/pluginrpc-gen/template.go:67:9: SA1019: strings.Title is deprecated: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead. (staticcheck)
        return strings.Title(s)
               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Mar 16, 2022
1 parent 5e330ad commit 4203a97
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion daemon/logger/templates/templates.go
Expand Up @@ -20,7 +20,7 @@ var basicFunctions = template.FuncMap{
},
"split": strings.Split,
"join": strings.Join,
"title": strings.Title,
"title": strings.Title, //nolint:staticcheck // SA1019: strings.Title is deprecated: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.
"lower": strings.ToLower,
"upper": strings.ToUpper,
"pad": padWithSpace,
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/pluginrpc-gen/template.go
Expand Up @@ -64,7 +64,7 @@ func title(s string) string {
if strings.ToLower(s) == "id" {
return "ID"
}
return strings.Title(s)
return strings.Title(s) //nolint:staticcheck // SA1019: strings.Title is deprecated: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.
}

var generatedTempl = template.Must(template.New("rpc_cient").Funcs(templFuncs).Parse(`
Expand Down

0 comments on commit 4203a97

Please sign in to comment.