diff --git a/.golangci.yml b/.golangci.yml index 219725df1..8acd0577a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,6 +5,7 @@ linters: default: none enable: - govet + - ineffassign # See: https://golangci-lint.run/usage/formatters/ formatters: diff --git a/pgconn/config.go b/pgconn/config.go index d5914aad9..a4cee7675 100644 --- a/pgconn/config.go +++ b/pgconn/config.go @@ -788,7 +788,7 @@ func configTLS(settings map[string]string, thisHost string, parseConfigOptions P // Attempt decryption with pass phrase // NOTE: only supports RSA (PKCS#1) if sslpassword != "" { - decryptedKey, decryptedError = x509.DecryptPEMBlock(block, []byte(sslpassword)) + decryptedKey, decryptedError = x509.DecryptPEMBlock(block, []byte(sslpassword)) //nolint:ineffassign } // if sslpassword not provided or has decryption error when use it // try to find sslpassword with callback function diff --git a/pgconn/ctxwatch/context_watcher_test.go b/pgconn/ctxwatch/context_watcher_test.go index 07c5e6323..ffb707997 100644 --- a/pgconn/ctxwatch/context_watcher_test.go +++ b/pgconn/ctxwatch/context_watcher_test.go @@ -116,6 +116,7 @@ func TestContextWatcherStress(t *testing.T) { for i := range cycleCount { ctx, cancel := context.WithCancel(context.Background()) + defer cancel() // satisfy linter; cancel is idempotent cw.Watch(ctx) if i%2 == 0 { cancel() diff --git a/pgconn/pgconn_test.go b/pgconn/pgconn_test.go index 4cc58a9ca..aac3162e1 100644 --- a/pgconn/pgconn_test.go +++ b/pgconn/pgconn_test.go @@ -2648,7 +2648,8 @@ func TestConnCloseWhileCancellableQueryInProgress(t *testing.T) { pgConn.Exec(ctx, "select n from generate_series(1,10) n") - closeCtx, _ := context.WithCancel(ctx) + closeCtx, closeCancel := context.WithCancel(ctx) + defer closeCancel() pgConn.Close(closeCtx) select { case <-pgConn.CleanupDone(): @@ -3909,7 +3910,7 @@ func TestSNISupport(t *testing.T) { _, port, _ := strings.Cut(ln.Addr().String(), ":") connStr := fmt.Sprintf("sslmode=require host=localhost port=%s %s", port, tt.sni_param) - _, err = pgconn.Connect(ctx, connStr) + _, _ = pgconn.Connect(ctx, connStr) select { case sniHost := <-serverSNINameChan: diff --git a/pgtype/array.go b/pgtype/array.go index 872a08891..4e0d6e0eb 100644 --- a/pgtype/array.go +++ b/pgtype/array.go @@ -299,7 +299,7 @@ func arrayParseQuotedValue(buf *bytes.Buffer) (string, bool, error) { return "", false, err } case '"': - r, _, err = buf.ReadRune() + _, _, err = buf.ReadRune() if err != nil { return "", false, err }