mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-06 09:44:24 +00:00
template: Use cases.Title instead of deprecated strings.Title (#15721)
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
a6947a0369
commit
4f67a38a39
@ -68,7 +68,7 @@ versions.
|
||||
|
||||
| Name | Arguments | Returns | Notes |
|
||||
| ------------- | ------------- | ------- | ----------- |
|
||||
| title | string | string | [strings.Title](https://golang.org/pkg/strings/#Title), capitalises first character of each word.|
|
||||
| title | string | string | [cases.Title](https://pkg.go.dev/golang.org/x/text/cases#Title), capitalises first character of each word.|
|
||||
| toUpper | string | string | [strings.ToUpper](https://golang.org/pkg/strings/#ToUpper), converts all characters to upper case.|
|
||||
| toLower | string | string | [strings.ToLower](https://golang.org/pkg/strings/#ToLower), converts all characters to lower case.|
|
||||
| stripPort | string | string | [net.SplitHostPort](https://pkg.go.dev/net#SplitHostPort), splits string into host and port, then returns only host.|
|
||||
|
@ -30,6 +30,8 @@ import (
|
||||
"github.com/grafana/regexp"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/common/model"
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
|
||||
common_templates "github.com/prometheus/common/helpers/templates"
|
||||
|
||||
@ -166,7 +168,7 @@ func NewTemplateExpander(
|
||||
return html_template.HTML(text)
|
||||
},
|
||||
"match": regexp.MatchString,
|
||||
"title": strings.Title, //nolint:staticcheck // TODO(beorn7): Need to come up with a replacement using the cases package.
|
||||
"title": cases.Title(language.AmericanEnglish, cases.NoLower).String,
|
||||
"toUpper": strings.ToUpper,
|
||||
"toLower": strings.ToLower,
|
||||
"graphLink": strutil.GraphLinkForExpression,
|
||||
|
Loading…
x
Reference in New Issue
Block a user