mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 09:26:43 -06:00
pkg/tsdb/graphite/graphite.go: Fix regular expression does not contain any meta characters.
I found this article benchmarking Replace vs Regexp, https://medium.com/codezillas/golang-replace-vs-regexp-de4e48482f53 See, $ gometalinter --vendor --deadline 10m --disable-all --enable=megacheck ./... pkg/tsdb/graphite/graphite.go:167:28⚠️ regular expression does not contain any meta characters (SA6004) (megacheck) pkg/tsdb/graphite/graphite.go:172:28⚠️ regular expression does not contain any meta characters (SA6004) (megacheck)
This commit is contained in:
parent
3466969a7c
commit
bb12a1bc99
@ -164,14 +164,12 @@ func formatTimeRange(input string) string {
|
||||
|
||||
func fixIntervalFormat(target string) string {
|
||||
rMinute := regexp.MustCompile(`'(\d+)m'`)
|
||||
rMin := regexp.MustCompile("m")
|
||||
target = rMinute.ReplaceAllStringFunc(target, func(m string) string {
|
||||
return rMin.ReplaceAllString(m, "min")
|
||||
return strings.Replace(m, "m", "min", -1)
|
||||
})
|
||||
rMonth := regexp.MustCompile(`'(\d+)M'`)
|
||||
rMon := regexp.MustCompile("M")
|
||||
target = rMonth.ReplaceAllStringFunc(target, func(M string) string {
|
||||
return rMon.ReplaceAllString(M, "mon")
|
||||
return strings.Replace(M, "M", "mon", -1)
|
||||
})
|
||||
return target
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user