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