{"modulePath":"gocloud.dev","version":"v0.49.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package gcppostgres\n\nPackage gcppostgres provides connections to managed PostgreSQL Cloud SQL instances. See [https://cloud.google.com/sql/docs/postgres/](https://cloud.google.com/sql/docs/postgres/) for more information.\n\n### URLs {#hdr-URLs}\n\nFor postgres.Open, gcppostgres registers for the scheme \"gcppostgres\". The default URL opener will create a connection using the default credentials from the environment, as described in [https://cloud.google.com/docs/authentication/production](https://cloud.google.com/docs/authentication/production). To customize the URL opener, or for more details on the URL format, see URLOpener.\n\n### IP Type {#hdr-IP_Type}\n\nBy default, connections use auto-IP selection (public IP if available, otherwise private IP), matching the behavior of the legacy cloudsql-proxy. To use a specific IP type, set URLOpener.IPType or pass the \"ip\\_type\" query parameter in the URL (requires URLOpener.Dialer to be set):\n\n\tgcppostgres://user:pass@project/region/instance/dbname?ip_type=psc\n\nValid values for ip\\_type: auto, public, private, psc.\n\nSee [https://gocloud.dev/concepts/urls/](https://gocloud.dev/concepts/urls/) for background information.\n\n## Constants\n\n```go\nconst Scheme = \"gcppostgres\"\n```\nScheme is the URL scheme gcppostgres registers its URLOpener under on postgres.DefaultMux.\n\n## Types\n\n```go\ntype URLOpener struct {\n\t// Dialer creates Cloud SQL connections using the Cloud SQL Go Connector.\n\t// Supports PSC and explicit IP type selection via the \"ip_type\" URL query\n\t// parameter. If both Dialer and CertSource are set, Dialer takes precedence.\n\tDialer *cloudsqlconn.Dialer\n\n\t// CertSource specifies how the opener will obtain authentication information.\n\t//\n\t// Deprecated: Use Dialer instead. CertSource does not support PSC or\n\t// explicit IP type selection. Ignored if Dialer is also set.\n\tCertSource proxy.CertSource\n\n\t// TraceOpts contains options for OpenTelemetry.\n\tTraceOpts []otelsql.Option\n}\n```\nURLOpener opens GCP PostgreSQL URLs like \"gcppostgres://user:password@myproject/us-central1/instanceId/mydb\".\n\n```go\nfunc (uo *URLOpener) OpenPostgresURL(ctx context.Context, u *url.URL) (*sql.DB, error)\n```\nOpenPostgresURL opens a new GCP database connection wrapped with OpenTelemetry instrumentation.\n\n","path":"gocloud.dev/postgres/gcppostgres","name":"gcppostgres","synopsis":"Package gcppostgres provides connections to managed PostgreSQL Cloud SQL instances.","isRedistributable":true}
