Skip to content

Commit

Permalink
Fix deprecated use of strings.Title (#119)
Browse files Browse the repository at this point in the history
* Fix deprecated use of strings.Title

* use language.Und
  • Loading branch information
fridgepoet authored Mar 30, 2022
1 parent 4cac61a commit 3bfbea9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ require (
github.com/grafana/grafana-plugin-sdk-go v0.125.0
github.com/stretchr/testify v1.7.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/text v0.3.6
)
6 changes: 4 additions & 2 deletions pkg/datasource/getInsights.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/backend/log"
"github.com/grafana/grafana-plugin-sdk-go/data"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

type GetInsightsQueryData struct {
Expand Down Expand Up @@ -123,7 +125,7 @@ func getInsightSummary(xrayClient XrayClient, query backend.DataQuery, states []
responseDataFrame.AppendRow(
insight.InsightId,
getDescription(insight, rootCauseService),
strings.Title(strings.ToLower(*insight.State)),
cases.Title(language.Und).String(strings.ToLower(*insight.State)),
getCategories(aws.StringValueSlice(insight.Categories)),
getDuration(insight.StartTime, insight.EndTime),
rootCauseService,
Expand All @@ -137,7 +139,7 @@ func getInsightSummary(xrayClient XrayClient, query backend.DataQuery, states []

func getCategories(categories []string) string {
for index, category := range categories {
categories[index] = strings.Title(strings.ToLower(category))
categories[index] = cases.Title(language.Und).String(strings.ToLower(category))
}
return strings.Join(categories, ", ")
}
Expand Down

0 comments on commit 3bfbea9

Please sign in to comment.