| 23 | ) |
| 24 | |
| 25 | func Example() { |
| 26 | // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored. |
| 27 | // PRAGMA: On gocloud.dev, add a blank import: _ "gocloud.dev/postgres/gcppostgres" |
| 28 | // PRAGMA: On gocloud.dev, hide lines until the next blank line. |
| 29 | ctx := context.Background() |
| 30 | |
| 31 | // Replace this with your actual settings. |
| 32 | db, err := postgres.Open(ctx, |
| 33 | "gcppostgres://user:password@example-project/region/my-instance01/testdb") |
| 34 | if err != nil { |
| 35 | log.Fatal(err) |
| 36 | } |
| 37 | defer db.Close() |
| 38 | |
| 39 | // Use database in your program. |
| 40 | db.Exec("CREATE TABLE foo (bar INT);") |
| 41 | } |