From 64cce683ccf8e495280f515b46a36f1cf081e8a2 Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Mon, 7 May 2018 15:39:54 +0300 Subject: [PATCH 1/2] gofmt -s. Signed-off-by: Alexey Palazhchenko --- db_test.go | 8 ++++---- fileutil/sync_linux.go | 2 +- head_test.go | 16 ++++++++-------- index/index_test.go | 12 ++++++------ index/postings_test.go | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/db_test.go b/db_test.go index 93d46f2b8..89d329b92 100644 --- a/db_test.go +++ b/db_test.go @@ -89,7 +89,7 @@ func TestDataAvailableOnlyAfterCommit(t *testing.T) { seriesSet = query(t, querier, labels.NewEqualMatcher("foo", "bar")) - testutil.Equals(t, seriesSet, map[string][]sample{`{foo="bar"}`: []sample{{t: 0, v: 0}}}) + testutil.Equals(t, seriesSet, map[string][]sample{`{foo="bar"}`: {{t: 0, v: 0}}}) } func TestDataNotAvailableAfterRollback(t *testing.T) { @@ -156,7 +156,7 @@ func TestDBAppenderAddRef(t *testing.T) { res := query(t, q, labels.NewEqualMatcher("a", "b")) testutil.Equals(t, map[string][]sample{ - labels.FromStrings("a", "b").String(): []sample{ + labels.FromStrings("a", "b").String(): { {t: 123, v: 0}, {t: 124, v: 1}, {t: 125, v: 0}, @@ -310,7 +310,7 @@ func TestSkippingInvalidValuesInSameTxn(t *testing.T) { ssMap := query(t, q, labels.NewEqualMatcher("a", "b")) testutil.Equals(t, map[string][]sample{ - labels.New(labels.Label{"a", "b"}).String(): []sample{{0, 1}}, + labels.New(labels.Label{"a", "b"}).String(): {{0, 1}}, }, ssMap) testutil.Ok(t, q.Close()) @@ -329,7 +329,7 @@ func TestSkippingInvalidValuesInSameTxn(t *testing.T) { ssMap = query(t, q, labels.NewEqualMatcher("a", "b")) testutil.Equals(t, map[string][]sample{ - labels.New(labels.Label{"a", "b"}).String(): []sample{{0, 1}, {10, 3}}, + labels.New(labels.Label{"a", "b"}).String(): {{0, 1}, {10, 3}}, }, ssMap) testutil.Ok(t, q.Close()) } diff --git a/fileutil/sync_linux.go b/fileutil/sync_linux.go index 1145904bf..1bbced915 100644 --- a/fileutil/sync_linux.go +++ b/fileutil/sync_linux.go @@ -31,4 +31,4 @@ func Fsync(f *os.File) error { // to be correctly handled. func Fdatasync(f *os.File) error { return syscall.Fdatasync(int(f.Fd())) -} \ No newline at end of file +} diff --git a/head_test.go b/head_test.go index 4ebf89164..caf4d652c 100644 --- a/head_test.go +++ b/head_test.go @@ -179,17 +179,17 @@ func TestHead_Truncate(t *testing.T) { testutil.Assert(t, postingsC1 == nil, "") testutil.Equals(t, map[string]struct{}{ - "": struct{}{}, // from 'all' postings list - "a": struct{}{}, - "b": struct{}{}, - "1": struct{}{}, - "2": struct{}{}, + "": {}, // from 'all' postings list + "a": {}, + "b": {}, + "1": {}, + "2": {}, }, h.symbols) testutil.Equals(t, map[string]stringset{ - "a": stringset{"1": struct{}{}, "2": struct{}{}}, - "b": stringset{"1": struct{}{}}, - "": stringset{"": struct{}{}}, + "a": {"1": struct{}{}, "2": struct{}{}}, + "b": {"1": struct{}{}}, + "": {"": struct{}{}}, }, h.values) } diff --git a/index/index_test.go b/index/index_test.go index 83b6ef657..f1b4d4181 100644 --- a/index/index_test.go +++ b/index/index_test.go @@ -192,12 +192,12 @@ func TestIndexRW_Postings(t *testing.T) { } err = iw.AddSymbols(map[string]struct{}{ - "a": struct{}{}, - "b": struct{}{}, - "1": struct{}{}, - "2": struct{}{}, - "3": struct{}{}, - "4": struct{}{}, + "a": {}, + "b": {}, + "1": {}, + "2": {}, + "3": {}, + "4": {}, }) testutil.Ok(t, err) diff --git a/index/postings_test.go b/index/postings_test.go index 9f8f71220..e7e2e61ca 100644 --- a/index/postings_test.go +++ b/index/postings_test.go @@ -371,7 +371,7 @@ func TestRemovedNextStackoverflow(t *testing.T) { for rp.Next() { gotElem = true } - + testutil.Ok(t, rp.Err()) testutil.Assert(t, !gotElem, "") } From 9283c68e7d4ffaffe8b7397874918ed27171eb0e Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Mon, 7 May 2018 16:02:49 +0300 Subject: [PATCH 2/2] Fix ineffective assignment. Signed-off-by: Alexey Palazhchenko --- wal.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wal.go b/wal.go index 8a2095aed..c1b9f6b06 100644 --- a/wal.go +++ b/wal.go @@ -937,7 +937,7 @@ func (r *walReader) Read( series = v.([]RefSeries) } - err := r.decodeSeries(flag, b, &series) + err = r.decodeSeries(flag, b, &series) if err != nil { err = errors.Wrap(err, "decode series entry") break @@ -958,7 +958,7 @@ func (r *walReader) Read( samples = v.([]RefSample) } - err := r.decodeSamples(flag, b, &samples) + err = r.decodeSamples(flag, b, &samples) if err != nil { err = errors.Wrap(err, "decode samples entry") break @@ -980,7 +980,7 @@ func (r *walReader) Read( deletes = v.([]Stone) } - err := r.decodeDeletes(flag, b, &deletes) + err = r.decodeDeletes(flag, b, &deletes) if err != nil { err = errors.Wrap(err, "decode delete entry") break