From 6380571e28109e0973d11971b4dac51da78a7265 Mon Sep 17 00:00:00 2001 From: Juraj Bubniak Date: Thu, 10 Oct 2024 21:06:02 +0200 Subject: [PATCH] Fix linter. --- connection.go | 8 ++++---- driver_test.go | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/connection.go b/connection.go index aa14ee3..f807cdb 100644 --- a/connection.go +++ b/connection.go @@ -7,9 +7,9 @@ import ( var ( _ driver.Pinger = (*connection)(nil) - _ driver.Execer = (*connection)(nil) + _ driver.Execer = (*connection)(nil) // nolint:staticcheck _ driver.ExecerContext = (*connection)(nil) - _ driver.Queryer = (*connection)(nil) + _ driver.Queryer = (*connection)(nil) // nolint:staticcheck _ driver.QueryerContext = (*connection)(nil) _ driver.Conn = (*connection)(nil) _ driver.ConnPrepareContext = (*connection)(nil) @@ -47,7 +47,7 @@ func (c *connection) BeginTx(ctx context.Context, opts driver.TxOptions) (driver } func (c *connection) Query(query string, args []driver.Value) (driver.Rows, error) { - queryer, ok := c.Conn.(driver.Queryer) + queryer, ok := c.Conn.(driver.Queryer) // nolint:staticcheck if !ok { return nil, driver.ErrSkip } @@ -63,7 +63,7 @@ func (c *connection) QueryContext(ctx context.Context, query string, args []driv } func (c *connection) Exec(query string, args []driver.Value) (driver.Result, error) { - execer, ok := c.Conn.(driver.Execer) + execer, ok := c.Conn.(driver.Execer) // nolint:staticcheck if !ok { return nil, driver.ErrSkip } diff --git a/driver_test.go b/driver_test.go index a81a994..6549bfa 100644 --- a/driver_test.go +++ b/driver_test.go @@ -19,7 +19,7 @@ func TestWrapDriver(t *testing.T) { { name: "QueryContext no attrs", perform: func(t *testing.T, ctx context.Context, db *sql.DB) { - db.QueryContext(ctx, "SELECT 1") + _, _ = db.QueryContext(ctx, "SELECT 1") }, assert: func(t *testing.T, conn *mockConn) { conn.assertQueryContext(t, "SELECT 1", 0) @@ -29,7 +29,7 @@ func TestWrapDriver(t *testing.T) { name: "QueryContext with attrs", options: []Option{WithAttrPairs("key", "value"), WithAttrPairs("key2", "value 2")}, perform: func(t *testing.T, ctx context.Context, db *sql.DB) { - db.QueryContext(ctx, "SELECT 1") + _, _ = db.QueryContext(ctx, "SELECT 1") }, assert: func(t *testing.T, conn *mockConn) { conn.assertQueryContext(t, "SELECT 1 /*key='value',key2='value%202'*/", 0) @@ -44,7 +44,7 @@ func TestWrapDriver(t *testing.T) { return withUserKey(context.Background(), "my-key") }, perform: func(t *testing.T, ctx context.Context, db *sql.DB) { - db.QueryContext(ctx, "SELECT 1") + _, _ = db.QueryContext(ctx, "SELECT 1") }, assert: func(t *testing.T, conn *mockConn) { conn.assertQueryContext(t, "SELECT 1 /*user-key='my-key'*/", 0) @@ -53,7 +53,7 @@ func TestWrapDriver(t *testing.T) { { name: "ExecContext no attrs", perform: func(t *testing.T, ctx context.Context, db *sql.DB) { - db.ExecContext(ctx, "UPDATE users SET name = 'joe'") + _, _ = db.ExecContext(ctx, "UPDATE users SET name = 'joe'") }, assert: func(t *testing.T, conn *mockConn) { conn.assertExecContext(t, "UPDATE users SET name = 'joe'", 0) @@ -63,7 +63,7 @@ func TestWrapDriver(t *testing.T) { name: "ExecContext with attrs", options: []Option{WithAttrPairs("key", "value")}, perform: func(t *testing.T, ctx context.Context, db *sql.DB) { - db.ExecContext(ctx, "UPDATE users SET name = 'joe'") + _, _ = db.ExecContext(ctx, "UPDATE users SET name = 'joe'") }, assert: func(t *testing.T, conn *mockConn) { conn.assertExecContext(t, "UPDATE users SET name = 'joe' /*key='value'*/", 0) @@ -78,7 +78,7 @@ func TestWrapDriver(t *testing.T) { return withUserKey(context.Background(), "my-key") }, perform: func(t *testing.T, ctx context.Context, db *sql.DB) { - db.ExecContext(ctx, "UPDATE users SET name = 'joe'") + _, _ = db.ExecContext(ctx, "UPDATE users SET name = 'joe'") }, assert: func(t *testing.T, conn *mockConn) { conn.assertExecContext(t, "UPDATE users SET name = 'joe' /*user-key='my-key'*/", 0) @@ -95,10 +95,10 @@ func TestWrapDriver(t *testing.T) { perform: func(t *testing.T, ctx context.Context, db *sql.DB) { tx, err := db.Begin() assertNoError(t, err) - defer tx.Commit() + defer func() { _ = tx.Commit() }() - tx.QueryContext(ctx, "SELECT 1") - tx.QueryContext(ctx, "SELECT 2") + _, _ = tx.QueryContext(ctx, "SELECT 1") + _, _ = tx.QueryContext(ctx, "SELECT 2") }, assert: func(t *testing.T, conn *mockConn) { conn.assertQueryContext(t, "SELECT 1 /*user-key='my-key'*/", 0) @@ -116,10 +116,10 @@ func TestWrapDriver(t *testing.T) { perform: func(t *testing.T, ctx context.Context, db *sql.DB) { tx, err := db.Begin() assertNoError(t, err) - defer tx.Commit() + defer func() { _ = tx.Commit() }() - tx.ExecContext(ctx, "UPDATE users SET name = 'joe'") - tx.ExecContext(ctx, "UPDATE users SET name = 'doe'") + _, _ = tx.ExecContext(ctx, "UPDATE users SET name = 'joe'") + _, _ = tx.ExecContext(ctx, "UPDATE users SET name = 'doe'") }, assert: func(t *testing.T, conn *mockConn) { conn.assertExecContext(t, "UPDATE users SET name = 'joe' /*user-key='my-key'*/", 0)