()
| 24 | ) |
| 25 | |
| 26 | func ExampleOpenBucket() { |
| 27 | // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored. |
| 28 | // PRAGMA: On gocloud.dev, hide lines until the next blank line. |
| 29 | ctx := context.Background() |
| 30 | |
| 31 | // Your GCP credentials. |
| 32 | // See https://cloud.google.com/docs/authentication/production |
| 33 | // for more info on alternatives. |
| 34 | creds, err := gcp.DefaultCredentials(ctx) |
| 35 | if err != nil { |
| 36 | log.Fatal(err) |
| 37 | } |
| 38 | |
| 39 | // Create an HTTP client. |
| 40 | // This example uses the default HTTP transport and the credentials |
| 41 | // created above. |
| 42 | client, err := gcp.NewHTTPClient( |
| 43 | gcp.DefaultTransport(), |
| 44 | gcp.CredentialsTokenSource(creds)) |
| 45 | if err != nil { |
| 46 | log.Fatal(err) |
| 47 | } |
| 48 | |
| 49 | // Create a *blob.Bucket. |
| 50 | bucket, err := gcsblob.OpenBucket(ctx, client, "my-bucket", nil) |
| 51 | if err != nil { |
| 52 | log.Fatal(err) |
| 53 | } |
| 54 | defer bucket.Close() |
| 55 | } |
| 56 | |
| 57 | func Example_openBucketFromURL() { |
| 58 | // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored. |
nothing calls this directly
no test coverage detected