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

Function ExampleListOptions

blob/example_test.go:481–515  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

479}
480
481func ExampleListOptions() {
482 // This example is specific to the gcsblob implementation; it demonstrates
483 // access to the underlying cloud.google.com/go/storage.Query type.
484 // The types exposed for As by gcsblob are documented in
485 // https://godoc.org/gocloud.dev/blob/gcsblob#hdr-As
486
487 ctx := context.Background()
488
489 b, err := blob.OpenBucket(ctx, "gs://my-bucket")
490 if err != nil {
491 log.Fatal(err)
492 }
493 defer b.Close()
494
495 beforeList := func(as func(any) bool) error {
496 // Access storage.Query via q here.
497 var q *storage.Query
498 if as(&q) {
499 _ = q.Delimiter
500 }
501 return nil
502 }
503
504 iter := b.List(&blob.ListOptions{Prefix: "", Delimiter: "/", BeforeList: beforeList})
505 for {
506 obj, err := iter.Next(ctx)
507 if err == io.EOF {
508 break
509 }
510 if err != nil {
511 log.Fatal(err)
512 }
513 _ = obj
514 }
515}
516
517func ExamplePrefixedBucket() {
518 // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored.

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected