MCPcopy Create free account
hub / github.com/google/go-cloud / ExampleOpen

Function ExampleOpen

postgres/example_test.go:24–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22)
23
24func 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}

Callers

nothing calls this directly

Calls 2

OpenFunction · 0.92
CloseMethod · 0.65

Tested by

no test coverage detected