Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectPgx ¶
func ConnectPgx( ctx context.Context, instURI, user, pass, dbname string, ) (*pgxpool.Pool, func() error, error)
connectPgx establishes a connection to your database using pgxpool and the AlloyDB Go Connector (aka alloydbconn.Dialer)
The function takes an instance URI, a username, a password, and a database name. Usage looks like this:
pool, cleanup, err := connectPgx( context.Background(), "projects/myproject/locations/us-central1/clusters/mycluster/instances/myinstance", "postgres", "secretpassword", "mydb", )
In addition to a *pgxpool.Pool type, the function returns a cleanup function that should be called when you're done with the database connection.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.