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

Function ExampleListObject_As

blob/example_test.go:450–479  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

448}
449
450func ExampleListObject_As() {
451 // This example is specific to the gcsblob implementation; it demonstrates
452 // access to the underlying cloud.google.com/go/storage.ObjectAttrs type.
453 // The types exposed for As by gcsblob are documented in
454 // https://godoc.org/gocloud.dev/blob/gcsblob#hdr-As
455
456 ctx := context.Background()
457
458 b, err := blob.OpenBucket(ctx, "gs://my-bucket")
459 if err != nil {
460 log.Fatal(err)
461 }
462 defer b.Close()
463
464 iter := b.List(nil)
465 for {
466 obj, err := iter.Next(ctx)
467 if err == io.EOF {
468 break
469 }
470 if err != nil {
471 log.Fatal(err)
472 }
473 // Access storage.ObjectAttrs via oa here.
474 var oa storage.ObjectAttrs
475 if obj.As(&oa) {
476 _ = oa.Owner
477 }
478 }
479}
480
481func ExampleListOptions() {
482 // This example is specific to the gcsblob implementation; it demonstrates

Callers

nothing calls this directly

Calls 5

OpenBucketFunction · 0.92
ListMethod · 0.80
CloseMethod · 0.65
NextMethod · 0.65
AsMethod · 0.65

Tested by

no test coverage detected