aboutsummaryrefslogtreecommitdiffhomepage
path: root/metrics
diff options
context:
space:
mode:
Diffstat (limited to 'metrics')
-rw-r--r--metrics/metrics.go10
-rw-r--r--metrics/metrics_test.go4
2 files changed, 7 insertions, 7 deletions
diff --git a/metrics/metrics.go b/metrics/metrics.go
index 12f825e19..9c46fdf7e 100644
--- a/metrics/metrics.go
+++ b/metrics/metrics.go
@@ -40,19 +40,19 @@ type Provider interface {
WriteMetrics(w io.Writer)
// TrackValue tracks the value for diff calculations etc.
- TrackValue(key string, value interface{}, cached bool)
+ TrackValue(key string, value any, cached bool)
// Reset clears the metric store.
Reset()
}
type diff struct {
- baseline interface{}
+ baseline any
count int
simSum int
}
-func (d *diff) add(v interface{}) *diff {
+func (d *diff) add(v any) *diff {
if types.IsNil(d.baseline) {
d.baseline = v
d.count = 1
@@ -103,7 +103,7 @@ func (s *Store) Reset() {
}
// TrackValue tracks the value for diff calculations etc.
-func (s *Store) TrackValue(key string, value interface{}, cached bool) {
+func (s *Store) TrackValue(key string, value any, cached bool) {
if !s.calculateHints {
return
}
@@ -207,7 +207,7 @@ func (b bySum) Less(i, j int) bool { return b[i].sum > b[j].sum }
// howSimilar is a naive diff implementation that returns
// a number between 0-100 indicating how similar a and b are.
-func howSimilar(a, b interface{}) int {
+func howSimilar(a, b any) int {
t1, t2 := reflect.TypeOf(a), reflect.TypeOf(b)
if t1 != t2 {
return 0
diff --git a/metrics/metrics_test.go b/metrics/metrics_test.go
index d28efa25e..d8c3237f8 100644
--- a/metrics/metrics_test.go
+++ b/metrics/metrics_test.go
@@ -41,8 +41,8 @@ func TestSimilarPercentage(t *testing.T) {
c.Assert(howSimilar("Totally different", "Not Same"), qt.Equals, 0)
c.Assert(howSimilar(sentence, sentenceReversed), qt.Equals, 14)
c.Assert(howSimilar(template.HTML("Hugo Rules"), template.HTML("Hugo Rules")), qt.Equals, 100)
- c.Assert(howSimilar(map[string]interface{}{"a": 32, "b": 33}, map[string]interface{}{"a": 32, "b": 33}), qt.Equals, 100)
- c.Assert(howSimilar(map[string]interface{}{"a": 32, "b": 33}, map[string]interface{}{"a": 32, "b": 34}), qt.Equals, 0)
+ c.Assert(howSimilar(map[string]any{"a": 32, "b": 33}, map[string]any{"a": 32, "b": 33}), qt.Equals, 100)
+ c.Assert(howSimilar(map[string]any{"a": 32, "b": 33}, map[string]any{"a": 32, "b": 34}), qt.Equals, 0)
}
type testStruct struct {