From bb95d09f9a07bc0fed10c4d1e8f5fe9d7c41883e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 31 Jan 2022 16:07:40 +0100 Subject: [PATCH] staticcheck: ignore "SA1019: strings.Title is deprecated" 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 (cherry picked from commit 4203a97aad9a7a54fe2d5354155eb7ef3ce0c7da) Signed-off-by: Sebastiaan van Stijn --- daemon/logger/templates/templates.go | 2 +- pkg/plugins/pluginrpc-gen/template.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/daemon/logger/templates/templates.go b/daemon/logger/templates/templates.go index ab76d0f1c2..d8b4ce5d85 100644 --- a/daemon/logger/templates/templates.go +++ b/daemon/logger/templates/templates.go @@ -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, diff --git a/pkg/plugins/pluginrpc-gen/template.go b/pkg/plugins/pluginrpc-gen/template.go index 50ed9293c1..c34a5add11 100644 --- a/pkg/plugins/pluginrpc-gen/template.go +++ b/pkg/plugins/pluginrpc-gen/template.go @@ -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(`