From 857a66025b5fad4f9fc07c3f7198ba45406e7d22 Mon Sep 17 00:00:00 2001 From: Benjamin Boudreau Date: Thu, 7 Aug 2025 14:14:53 -0400 Subject: [PATCH] mention pgxpool in go and pgx guide --- docs/guides/using-go-and-pgx.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/guides/using-go-and-pgx.rst b/docs/guides/using-go-and-pgx.rst index 636434d3af..68e2242926 100644 --- a/docs/guides/using-go-and-pgx.rst +++ b/docs/guides/using-go-and-pgx.rst @@ -109,3 +109,25 @@ pgx types directly. fmt.Println(author.Name) } + +.. note:: + For production applications, consider using pgxpool for connection pooling: + + .. code-block:: go + + import ( + "github.com/jackc/pgx/v5/pgxpool" + "example.com/sqlc-tutorial/db" + ) + + func main() { + pool, err := pgxpool.New(context.Background(), os.Getenv("DATABASE_URL")) + if err != nil { + fmt.Fprintf(os.Stderr, "Unable to create connection pool: %v\n", err) + os.Exit(1) + } + defer pool.Close() + + q := db.New(pool) + // Use q the same way as with single connections + }