From f3f5b70a872eb9875c7bc0cbc6f7b3876c08d92b Mon Sep 17 00:00:00 2001 From: Feike Steenbergen Date: Thu, 29 Oct 2020 18:59:15 +0100 Subject: [PATCH] Ensure the example code snippet compiles again There were 2 errors when using the example code: - not enough arguments in call to pgConn.Close - no new variables on left side of := With these changes, the example works again. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 5d14e914..6a68e230 100644 --- a/README.md +++ b/README.md @@ -15,16 +15,16 @@ pgConn, err := pgconn.Connect(context.Background(), os.Getenv("DATABASE_URL")) if err != nil { log.Fatalln("pgconn failed to connect:", err) } -defer pgConn.Close() +defer pgConn.Close(context.Background()) result := pgConn.ExecParams(context.Background(), "SELECT email FROM users WHERE id=$1", [][]byte{[]byte("123")}, nil, nil, nil) for result.NextRow() { fmt.Println("User 123 has email:", string(result.Values()[0])) } -_, err := result.Close() +_, err = result.Close() if err != nil { log.Fatalln("failed reading result:", err) -}) +} ``` ## Testing