From fd8edfd1ffe0882d43f99e25431021f31f7f5687 Mon Sep 17 00:00:00 2001 From: Andrew Mason Date: Thu, 29 Apr 2021 08:42:16 -0400 Subject: [PATCH] Fix errchecks in a few places Signed-off-by: Andrew Mason --- go/cache/ristretto/bloom/bbloom_test.go | 2 +- go/streamlog/streamlog.go | 2 +- go/streamlog/streamlog_flaky_test.go | 2 +- go/vt/binlog/tables_filter_test.go | 8 ++++---- go/vt/dbconfigs/dbconfigs_test.go | 2 +- go/vt/vtadmin/cluster/cluster_test.go | 2 +- go/vt/vtgate/engine/set.go | 2 +- .../queryservice/fakes/stream_health_query_service.go | 2 +- go/vt/vttablet/tabletmanager/rpc_query.go | 4 ++-- go/vt/vttablet/tabletmanager/rpc_schema.go | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/go/cache/ristretto/bloom/bbloom_test.go b/go/cache/ristretto/bloom/bbloom_test.go index 960fb034e6..c0f9a916d1 100644 --- a/go/cache/ristretto/bloom/bbloom_test.go +++ b/go/cache/ristretto/bloom/bbloom_test.go @@ -19,7 +19,7 @@ func TestMain(m *testing.M) { wordlist1 = make([][]byte, n) for i := range wordlist1 { b := make([]byte, 32) - rand.Read(b) + _, _ = rand.Read(b) wordlist1[i] = b } fmt.Println("\n###############\nbbloom_test.go") diff --git a/go/streamlog/streamlog.go b/go/streamlog/streamlog.go index 32fdb6be24..53636264d9 100644 --- a/go/streamlog/streamlog.go +++ b/go/streamlog/streamlog.go @@ -179,7 +179,7 @@ func (logger *StreamLogger) LogToFile(path string, logf LogFormatter) (chan inte for { select { case record := <-logChan: - logf(f, formatParams, record) + logf(f, formatParams, record) // nolint:errcheck case <-rotateChan: f.Close() f, _ = os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) diff --git a/go/streamlog/streamlog_flaky_test.go b/go/streamlog/streamlog_flaky_test.go index 1dd987da5a..8c67b57abb 100644 --- a/go/streamlog/streamlog_flaky_test.go +++ b/go/streamlog/streamlog_flaky_test.go @@ -235,7 +235,7 @@ func TestFile(t *testing.T) { // Send the rotate signal which should reopen the original file path // for new logs to go to - syscall.Kill(syscall.Getpid(), syscall.SIGUSR2) + _ = syscall.Kill(syscall.Getpid(), syscall.SIGUSR2) time.Sleep(10 * time.Millisecond) logger.Send(&logMessage{"test 4"}) diff --git a/go/vt/binlog/tables_filter_test.go b/go/vt/binlog/tables_filter_test.go index aa4fa36b77..abdf8a44b6 100644 --- a/go/vt/binlog/tables_filter_test.go +++ b/go/vt/binlog/tables_filter_test.go @@ -58,7 +58,7 @@ func TestTablesFilterPass(t *testing.T) { got = bltToString(reply) return nil }) - f(eventToken, statements) + _ = f(eventToken, statements) want := `statement: <6, "set1"> statement: <7, "dml1 /* _stream included1 (id ) (500 ); */"> statement: <7, "dml2 /* _stream included2 (id ) (500 ); */"> position: "MariaDB/0-41983-1" ` if want != got { t.Errorf("want\n%s, got\n%s", want, got) @@ -88,7 +88,7 @@ func TestTablesFilterSkip(t *testing.T) { got = bltToString(reply) return nil }) - f(eventToken, statements) + _ = f(eventToken, statements) want := `position: "MariaDB/0-41983-1" ` if want != got { t.Errorf("want %s, got %s", want, got) @@ -118,7 +118,7 @@ func TestTablesFilterDDL(t *testing.T) { got = bltToString(reply) return nil }) - f(eventToken, statements) + _ = f(eventToken, statements) want := `position: "MariaDB/0-41983-1" ` if want != got { t.Errorf("want %s, got %s", want, got) @@ -154,7 +154,7 @@ func TestTablesFilterMalformed(t *testing.T) { got = bltToString(reply) return nil }) - f(eventToken, statements) + _ = f(eventToken, statements) want := `position: "MariaDB/0-41983-1" ` if want != got { t.Errorf("want %s, got %s", want, got) diff --git a/go/vt/dbconfigs/dbconfigs_test.go b/go/vt/dbconfigs/dbconfigs_test.go index 7ddc131564..2223990d6c 100644 --- a/go/vt/dbconfigs/dbconfigs_test.go +++ b/go/vt/dbconfigs/dbconfigs_test.go @@ -283,7 +283,7 @@ func hupTest(t *testing.T, tmpFile *os.File, oldStr, newStr string) { if pass != oldStr { t.Fatalf("%s's Password should still be '%s'", oldStr, oldStr) } - syscall.Kill(syscall.Getpid(), syscall.SIGHUP) + _ = syscall.Kill(syscall.Getpid(), syscall.SIGHUP) time.Sleep(100 * time.Millisecond) // wait for signal handler _, _, err := cs.GetUserAndPassword(oldStr) if err != ErrUnknownUser { diff --git a/go/vt/vtadmin/cluster/cluster_test.go b/go/vt/vtadmin/cluster/cluster_test.go index 7a77598a75..0c88ea69ce 100644 --- a/go/vt/vtadmin/cluster/cluster_test.go +++ b/go/vt/vtadmin/cluster/cluster_test.go @@ -791,7 +791,7 @@ func TestGetSchema(t *testing.T) { err := c.Vtctld.Dial(ctx) require.NoError(t, err, "could not dial test vtctld") - c.GetSchema(ctx, "testkeyspace", cluster.GetSchemaOptions{ + _, _ = c.GetSchema(ctx, "testkeyspace", cluster.GetSchemaOptions{ BaseRequest: req, Tablets: []*vtadminpb.Tablet{tablet}, }) diff --git a/go/vt/vtgate/engine/set.go b/go/vt/vtgate/engine/set.go index f15c506c50..cdf13da57d 100644 --- a/go/vt/vtgate/engine/set.go +++ b/go/vt/vtgate/engine/set.go @@ -382,7 +382,7 @@ func (svss *SysVarSetAware) Execute(vcursor VCursor, env evalengine.ExpressionEn if err != nil { return err } - vcursor.Session().SetSQLSelectLimit(intValue) + vcursor.Session().SetSQLSelectLimit(intValue) // nolint:errcheck case sysvars.TransactionMode.Name: str, err := svss.evalAsString(env) if err != nil { diff --git a/go/vt/vttablet/queryservice/fakes/stream_health_query_service.go b/go/vt/vttablet/queryservice/fakes/stream_health_query_service.go index d3426e96df..24882d84d4 100644 --- a/go/vt/vttablet/queryservice/fakes/stream_health_query_service.go +++ b/go/vt/vttablet/queryservice/fakes/stream_health_query_service.go @@ -72,7 +72,7 @@ func (q *StreamHealthQueryService) Execute(ctx context.Context, target *querypb. // the healthcheck module. func (q *StreamHealthQueryService) StreamHealth(ctx context.Context, callback func(*querypb.StreamHealthResponse) error) error { for shr := range q.healthResponses { - callback(shr) + callback(shr) // nolint:errcheck } return nil } diff --git a/go/vt/vttablet/tabletmanager/rpc_query.go b/go/vt/vttablet/tabletmanager/rpc_query.go index 1372052643..419124e7b4 100644 --- a/go/vt/vttablet/tabletmanager/rpc_query.go +++ b/go/vt/vttablet/tabletmanager/rpc_query.go @@ -46,7 +46,7 @@ func (tm *TabletManager) ExecuteFetchAsDba(ctx context.Context, query []byte, db if dbName != "" { // This execute might fail if db does not exist. // Error is ignored because given query might create this database. - conn.ExecuteFetch("USE "+sqlescape.EscapeID(dbName), 1, false) + _, _ = conn.ExecuteFetch("USE "+sqlescape.EscapeID(dbName), 1, false) } // run the query @@ -83,7 +83,7 @@ func (tm *TabletManager) ExecuteFetchAsAllPrivs(ctx context.Context, query []byt if dbName != "" { // This execute might fail if db does not exist. // Error is ignored because given query might create this database. - conn.ExecuteFetch("USE "+sqlescape.EscapeID(dbName), 1, false) + _, _ = conn.ExecuteFetch("USE "+sqlescape.EscapeID(dbName), 1, false) } // run the query diff --git a/go/vt/vttablet/tabletmanager/rpc_schema.go b/go/vt/vttablet/tabletmanager/rpc_schema.go index 5a5b1425d6..879dc63001 100644 --- a/go/vt/vttablet/tabletmanager/rpc_schema.go +++ b/go/vt/vttablet/tabletmanager/rpc_schema.go @@ -89,6 +89,6 @@ func (tm *TabletManager) ApplySchema(ctx context.Context, change *tmutils.Schema } // and if it worked, reload the schema - tm.ReloadSchema(ctx, "") + tm.ReloadSchema(ctx, "") // nolint:errcheck return scr, nil }