diff --git a/Makefile b/Makefile index 2015d6e0e..20db96a52 100644 --- a/Makefile +++ b/Makefile @@ -27,8 +27,8 @@ release: victoria-metrics-prod cd bin && tar czf victoria-metrics-$(PKG_TAG).tar.gz victoria-metrics-prod fmt: - go fmt $(PKG_PREFIX)/lib/... - go fmt $(PKG_PREFIX)/app/... + gofmt -l -w -s ./lib + gofmt -l -w -s ./app vet: go vet $(PKG_PREFIX)/lib/... diff --git a/app/vmselect/promql/rollup_result_cache_test.go b/app/vmselect/promql/rollup_result_cache_test.go index e2cdfac2e..7d76ad156 100644 --- a/app/vmselect/promql/rollup_result_cache_test.go +++ b/app/vmselect/promql/rollup_result_cache_test.go @@ -39,7 +39,7 @@ func TestRollupResultCache(t *testing.T) { t.Run("start-overlap", func(t *testing.T) { ResetRollupResultCache() tss := []*timeseries{ - ×eries{ + { Timestamps: []int64{800, 1000, 1200}, Values: []float64{0, 1, 2}, }, @@ -50,7 +50,7 @@ func TestRollupResultCache(t *testing.T) { t.Fatalf("unexpected newStart; got %d; want %d", newStart, 1400) } tssExpected := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200}, Values: []float64{1, 2}, }, @@ -62,7 +62,7 @@ func TestRollupResultCache(t *testing.T) { t.Run("end-overlap", func(t *testing.T) { ResetRollupResultCache() tss := []*timeseries{ - ×eries{ + { Timestamps: []int64{1800, 2000, 2200, 2400}, Values: []float64{333, 0, 1, 2}, }, @@ -81,7 +81,7 @@ func TestRollupResultCache(t *testing.T) { t.Run("full-cover", func(t *testing.T) { ResetRollupResultCache() tss := []*timeseries{ - ×eries{ + { Timestamps: []int64{1200, 1400, 1600}, Values: []float64{0, 1, 2}, }, @@ -100,7 +100,7 @@ func TestRollupResultCache(t *testing.T) { t.Run("before-start", func(t *testing.T) { ResetRollupResultCache() tss := []*timeseries{ - ×eries{ + { Timestamps: []int64{200, 400, 600}, Values: []float64{0, 1, 2}, }, @@ -119,7 +119,7 @@ func TestRollupResultCache(t *testing.T) { t.Run("after-end", func(t *testing.T) { ResetRollupResultCache() tss := []*timeseries{ - ×eries{ + { Timestamps: []int64{2200, 2400, 2600}, Values: []float64{0, 1, 2}, }, @@ -138,7 +138,7 @@ func TestRollupResultCache(t *testing.T) { t.Run("bigger-than-start-end", func(t *testing.T) { ResetRollupResultCache() tss := []*timeseries{ - ×eries{ + { Timestamps: []int64{800, 1000, 1200, 1400, 1600, 1800, 2000, 2200}, Values: []float64{0, 1, 2, 3, 4, 5, 6, 7}, }, @@ -149,7 +149,7 @@ func TestRollupResultCache(t *testing.T) { t.Fatalf("unexpected newStart; got %d; want %d", newStart, 2200) } tssExpected := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Values: []float64{1, 2, 3, 4, 5, 6}, }, @@ -161,7 +161,7 @@ func TestRollupResultCache(t *testing.T) { t.Run("start-end-match", func(t *testing.T) { ResetRollupResultCache() tss := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Values: []float64{1, 2, 3, 4, 5, 6}, }, @@ -172,7 +172,7 @@ func TestRollupResultCache(t *testing.T) { t.Fatalf("unexpected newStart; got %d; want %d", newStart, 2200) } tssExpected := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Values: []float64{1, 2, 3, 4, 5, 6}, }, @@ -203,19 +203,19 @@ func TestRollupResultCache(t *testing.T) { t.Run("multi-timeseries", func(t *testing.T) { ResetRollupResultCache() tss1 := []*timeseries{ - ×eries{ + { Timestamps: []int64{800, 1000, 1200}, Values: []float64{0, 1, 2}, }, } tss2 := []*timeseries{ - ×eries{ + { Timestamps: []int64{1800, 2000, 2200, 2400}, Values: []float64{333, 0, 1, 2}, }, } tss3 := []*timeseries{ - ×eries{ + { Timestamps: []int64{1200, 1400, 1600}, Values: []float64{0, 1, 2}, }, @@ -228,7 +228,7 @@ func TestRollupResultCache(t *testing.T) { t.Fatalf("unexpected newStart; got %d; want %d", newStart, 1400) } tssExpected := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200}, Values: []float64{1, 2}, }, @@ -249,14 +249,14 @@ func TestMergeTimeseries(t *testing.T) { t.Run("bStart=ec.Start", func(t *testing.T) { a := []*timeseries{} b := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Values: []float64{1, 2, 3, 4, 5, 6}, }, } tss := mergeTimeseries(a, b, 1000, ec) tssExpected := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Values: []float64{1, 2, 3, 4, 5, 6}, }, @@ -266,14 +266,14 @@ func TestMergeTimeseries(t *testing.T) { t.Run("a-empty", func(t *testing.T) { a := []*timeseries{} b := []*timeseries{ - ×eries{ + { Timestamps: []int64{1400, 1600, 1800, 2000}, Values: []float64{3, 4, 5, 6}, }, } tss := mergeTimeseries(a, b, bStart, ec) tssExpected := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Values: []float64{nan, nan, 3, 4, 5, 6}, }, @@ -282,7 +282,7 @@ func TestMergeTimeseries(t *testing.T) { }) t.Run("b-empty", func(t *testing.T) { a := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200}, Values: []float64{2, 1}, }, @@ -290,7 +290,7 @@ func TestMergeTimeseries(t *testing.T) { b := []*timeseries{} tss := mergeTimeseries(a, b, bStart, ec) tssExpected := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Values: []float64{2, 1, nan, nan, nan, nan}, }, @@ -299,20 +299,20 @@ func TestMergeTimeseries(t *testing.T) { }) t.Run("non-empty", func(t *testing.T) { a := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200}, Values: []float64{2, 1}, }, } b := []*timeseries{ - ×eries{ + { Timestamps: []int64{1400, 1600, 1800, 2000}, Values: []float64{3, 4, 5, 6}, }, } tss := mergeTimeseries(a, b, bStart, ec) tssExpected := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Values: []float64{2, 1, 3, 4, 5, 6}, }, @@ -321,14 +321,14 @@ func TestMergeTimeseries(t *testing.T) { }) t.Run("non-empty-distinct-metric-names", func(t *testing.T) { a := []*timeseries{ - ×eries{ + { Timestamps: []int64{1000, 1200}, Values: []float64{2, 1}, }, } a[0].MetricName.MetricGroup = []byte("bar") b := []*timeseries{ - ×eries{ + { Timestamps: []int64{1400, 1600, 1800, 2000}, Values: []float64{3, 4, 5, 6}, }, @@ -336,14 +336,14 @@ func TestMergeTimeseries(t *testing.T) { b[0].MetricName.MetricGroup = []byte("foo") tss := mergeTimeseries(a, b, bStart, ec) tssExpected := []*timeseries{ - ×eries{ + { MetricName: storage.MetricName{ MetricGroup: []byte("foo"), }, Timestamps: []int64{1000, 1200, 1400, 1600, 1800, 2000}, Values: []float64{nan, nan, 3, 4, 5, 6}, }, - ×eries{ + { MetricName: storage.MetricName{ MetricGroup: []byte("bar"), }, diff --git a/lib/storage/partition_test.go b/lib/storage/partition_test.go index cf828967f..f87d7d64f 100644 --- a/lib/storage/partition_test.go +++ b/lib/storage/partition_test.go @@ -112,15 +112,15 @@ func testAppendPartsToMerge(t *testing.T, maxPartsToMerge int, initialRowsCount, // Verify appending to prefix prefix := []*partWrapper{ - &partWrapper{ + { p: &part{ ph: partHeader{ RowsCount: 1234, }, }, }, - &partWrapper{}, - &partWrapper{}, + {}, + {}, } pms = appendPartsToMerge(prefix, pws, maxPartsToMerge, 1e9) if !reflect.DeepEqual(pms[:len(prefix)], prefix) {